$form = Fieldset::forge('my_form');
$fieldset = array(
'username'=>array(
array(),//attrs
array('required')//rules
),
....
);
foreach($fieldset as $field=>$params){
$attrs = Arr::get($params,0);
$rules = Arr::get($params,1);
$form -> add($field, $field, $attrs, $rules);
}
$form -> add('action', NULL, array('type' => 'hidden', 'value' => 'action_name'));
$form -> add('submit', NULL, array('type' => 'submit', 'class' => 'right button', 'value' => 'submit' ));
if (Input::post('action') == 'action_name') {
if(!$form->validation()->run()){
echo $form->show_errors();
$form -> repopulate();
}
}
echo $form -> build();
public function action_actions() {
if (Input::post('action') == 'action_name') {
$form = Fieldset::Instance('my_form');
if($form->validation()->run()){
Model_Actions::add($form->validated());
Response::redirect(Uri::create('actions/welcome'));
}
}
.....
It looks like you're new here. If you want to get involved, click one of these buttons!