Redaxscript\Html\Form::label PHP Method

label() public method

append the label
Since: 3.0.0
public label ( string $html = null, array $attributeArray = [] ) : Form
$html string html of the label
$attributeArray array attributes of the label
return Form
    public function label($html = null, $attributeArray = [])
    {
        if (is_array($attributeArray)) {
            $attributeArray = array_merge($this->_attributeArray['label'], $attributeArray);
        } else {
            $attributeArray = $this->_attributeArray['label'];
        }
        $labelElement = new Element();
        $labelElement->init('label', $attributeArray)->html($html);
        $this->append($labelElement);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('consoleFormStart');
     /* html elements */
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-console-js-form rs-console-form-default']]);
     $myUser = $this->_registry->get('myUser');
     $outputLabel = $myUser ? $myUser . '@' : null;
     $outputLabel .= $this->_registry->get('host') . ':~$';
     /* create the form */
     $formElement->label($outputLabel, ['class' => 'rs-console-js-label rs-console-label-default', 'for' => 'prompt'])->text(['autocapitalize' => 'off', 'autofocus' => 'autofocus', 'autocomplete' => 'off', 'class' => 'rs-console-js-field rs-console-field-text', 'id' => 'prompt', 'name' => 'argv', 'spellcheck' => 'false']);
     /* collect output */
     $output .= $formElement;
     $output .= Hook::trigger('consoleFormEnd');
     return $output;
 }
All Usage Examples Of Redaxscript\Html\Form::label