Hello, please, explain why it is not clear working class automatic form generation and validation
For example I have a users table 50 fields, the model user, I fully described all the validation rules
<?phpclass Model_User extends \Orm\Model
{
protected static $_properties = array(
'id','username' => array(
'data_type' => 'string',
'validation' => array('required', 'trim', 'min_length'=>array(3), 'max_length'=>array(30)),
'label' => array('label'=>'Username', 'class'=>'control-label'),
),
'password' => array(
'data_type' => 'string',
'validation' => array('required', 'trim', 'min_length'=>array(6), 'max_length'=>array(30)),
'label' => array('label'=>'Password', 'class'=>'control-label'),
), .....?>
Now I can create a form with the required I immediately checks validation class
<?php
$user = Model_User::forge();
$form->form()->add_model($user)->repopulate();
....
?>
but there is one problem you will see all the fields that are in the table, and if I need to do some optional fields, username, password, email
You can display a field in a class method fieldset add
<?php
$fieldset = Fieldset::forge()->repopulate();
$form = $fieldset->form()->set_attribute('class', 'form-horizontal');
$form->add('username, 'Username'......')?>
but there is another problem why the need to re-describe the validation rules for the fields, although they have been described in the user model
may have some other way to allow you to selectively display the required fields and validation rules that were taken from the model?
<?php<br />echo Form::open(array('class' => 'form-horizontal'));
$fieldset = Fieldset::forge()->add_model('Model_User')->repopulate();
echo $fieldset->field('username')->build();
echo $fieldset->field('password')->build();
echo Form::button('submit', 'Sign in', array('type' => 'submit', 'class' => 'btn btn-primary'));
echo Form::close();
?>
It looks like you're new here. If you want to get involved, click one of these buttons!