flsouto / httextar
There is no license information available for the latest version (1.0.0) of this package.
Creates textarea fields
1.0.0
2017-02-11 22:58 UTC
Requires
- flsouto/httextin: ^1.0
This package is not auto-updated.
Last update: 2025-01-27 16:11:55 UTC
README
Produces Textareas. This is an extension of the HtTextin class.
Installation
Run composer:
composer require flsouto/httextar
Usage
By default, the textar
widget is rendered in writable mode. See example:
<?php use FlSouto\HtTextar; require_once('vendor/autoload.php'); $field = new HtTextar('description'); $field->context(['description'=>'This is a very long description']); echo $field;
Outputs:
<div class="widget 589f96dbdf794" style="display:block"> <textarea name="description" cols="40" rows="4">This is a very long description</textarea> <div style="color:yellow;background:red" class="error"> </div> </div>
Switch to Readonly
Use the readonly
method to switch to readonly mode:
use FlSouto\HtTextar; require_once('vendor/autoload.php'); $field = new HtTextar('description'); $field->readonly(); $field->context(['description'=>'This is a very long description']); echo $field;
Outputs:
<div class="widget 589f96dbe11ec" style="display:block"> <textarea name="description" cols="40" rows="4" readonly="readonly">This is a very long description</textarea> <div style="color:yellow;background:red" class="error"> </div> </div>
Setting dimensions of textarea
You can set the cols
and rows
attributes by using the respective methods:
use FlSouto\HtTextar; $field = new HtTextar('description'); $field->cols(80)->rows(10); echo $field;
Outputs:
<div class="widget 589f96dbe171b" style="display:block"> <textarea name="description" cols="80" rows="10"></textarea> <div style="color:yellow;background:red" class="error"> </div> </div>
Notice: this is only a shortcut to calling $field->attrs(['cols'=>80,'rows'=>10])
Alternative syntax for setting dimensions
You can use the size
method passing a string in the format "COLSxROWS" to set both dimensions in one go:
$field = new HtTextar('description'); $field->size('80x10'); echo $field;
Output:
<div class="widget 589f96dbe1c28" style="display:block"> <textarea name="description" cols="80" rows="10"></textarea> <div style="color:yellow;background:red" class="error"> </div> </div>
To learn more about everything you can do with this widget, please refer to the following documentations: