Search
 
SCRIPT & CODE EXAMPLE
 

PHP

MForm Attribute für Felder

<?php
// init mform
$mform = MForm::factory()
    // text input use set attribute method
    ->addTextField("1.0")
    ->setAttribute('label', 'Text Label')
    ->setAttribute('class', 'mynewclass')
    ->setAttribute('style', 'width: 260px')
    ->setAttribute('default-value', 'default value string');

// text input use set attributes method
$mform->addTextField(1.2)
    ->setAttributes([
        'label'=>'Text Label',
        'class'=>'mynewclass',
        'style'=>'width: 220px',
        'default-value'=>'default value string'
    ]);

// text input use add method attributes parameter
$mform->addTextField(1.3, [
    'label'=>'Text Label',
    'class'=>'mynewclass',
    'style'=>'width: 280px',
    'default-value'=>'default value string'
]);

// text input use any set methods
$mform->addTextField(1.4)
    ->setLabel('Text Label') // for label use set label method
    ->setAttribute('class', 'mynewclass') // for class use only set attribute method
    ->setAttribute('style', 'width: 220px') // for style use only set attribute method
    ->setDefaultValue('default value string'); // for default value use set default value method

// init mform
$mform2 = MForm::factory()
    // select use add method attributes parameter
    ->addSelectField("2.0", [1 => 'option 1', 2 => 'option 2'], [
        'label'=>'Select Label',
        'class'=>'mynewclass',
        'style'=>'width: 260px',
        'default-value'=>2
    ]);

// select use set attributes method
$mform->addSelectField(2.1, [1 => 'option 1', 2 => 'option 2'])
    ->setAttributes([
        'label'=>'Select Label',
        'class'=>'mynewclass',
        'style'=>'width: 220px',
        'default-value'=>2
    ]);

// select use any setters
$mform->addSelectField(2.2)
    ->setOptions([1 => 'option 1', 2 => 'option 2', 3 => 'option 3', 4 => 'option 4']) // for options set options method
    ->setOption('option 5', 5)
    ->setLabel('Select Label') // for label use set label method
    ->setAttribute('class', 'mynewclass') // for class use only set attribute method
    ->setAttribute('style', 'width: 260px') // for style use only set attribute method
    ->setDefaultValue(2) // for default value use set default value method
    ->setMultiple()
    ->setSize('full');

// parse mform
echo MForm::factory()
    // add fieldset areas
    ->addFieldsetArea('Fieldset Element', $mform)
    ->addFieldsetArea('Select elements with attributes', $mform2)
    ->show();
Comment

PREVIOUS NEXT
Code Example
Php :: laravel faker car plate br mercossul 
Php :: how to claer the input php 
Php :: The blade is not updated with minor changes to the first blade 
Php :: php in array key 
Php :: php form detect if number has decimals 
Php :: print value in laravel console 
Php :: foreach range php 
Php :: php validate name 
Php :: php remove space before and after string 
Php :: customer io send_at api 
Php :: laravel current timestamp 
Php :: php extract email address from string 
Php :: laravel blade auth check 
Php :: incorrect format parameter phpmyadmin xampp 
Php :: Yii2 Fatal Error: Require_Once() 
Php :: php microtime 
Php :: how to forget session in laravel 
Php :: Detecting russian characters on a form in PHP 
Php :: php show number 4 digit 
Php :: remove special character in php 
Php :: how check if method is not in class in php 
Php :: verificare esistenza file in php 
Php :: how to print all session variables in php 
Php :: carbon 2 days ago 
Php :: laravel get authorization bearer token 
Php :: laravel download file from public folder 
Php :: laravel eloquent randomise data from database 
Php :: convert post name to id 
Php :: php artisan cache 
Php :: insert php variable css 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =