Form->create('Form', array('url' => $action)); if(isset($formFields['FormField'])){ foreach($formFields['FormField'] as $field){ $out .= $this->field($field); } } if($this->openFieldset == true){ $out .= ""; } $out .= $this->Form->end('Submit'); return $this->output($out); } /** * Generates appropriate html per field * * @param array $field Field to process * @parram array $custom_options Custom $form->input options for field * * @return string field html * @access public */ function field($field, $custom_options = array()){ $options = array(); $out = ''; if(!empty($field['type'])){ switch($field['type']){ case 'fieldset': if($this->openFieldset == true){ $out .= ""; } $out .= "
"; $this->openFieldset = true; if(!empty($field['name'])){ $out .= "".Inflector::humanize($field['name']).""; $out .= $this->Form->hidden('fs_' . $field['name'], array('value' => $field['name'])); } break; case 'textonly': $out = $this->Html->para('textonly', $field['label']); break; default: $options['type'] = $field['type']; if(in_array($field['type'], array('select', 'checkbox', 'radio'))){ if($field['type'] == 'checkbox'){ if(count($field['options']) > 1){ $options['type'] = 'select'; $options['multiple'] = 'checkbox'; $options['options'] = $field['options']; } else { $options['value'] = $field['name']; } } else { $options['options'] = $field['options']; $options['empty'] = 'select one'; } } if(!empty($field['depends_on']) && !empty($field['depends_value'])){ $options['class'] = 'dependent'; $options['dependsOn'] = $field['depends_on']; $options['dependsValue'] = $field['depends_value']; } if(!empty($field['label'])){ $options['label'] = $field['label']; if($field['type'] == 'radio'){ $options['legend'] = $field['label']; } } if($field['type'] == 'radio' && count($field['options']) == 2 ){ $options['div'] = 'input radio bool'; $options['legend'] = false; $options['before'] = $this->Html->div('radio-label', $field['label']); } if(!empty($field['default']) && empty($this->data['Form'][$field['name']])){ $options['value'] = $field['default']; } $options = Set::merge($custom_options, $options); $out .= $this->Form->input($field['name'], $options); break; } } return $out; } } ?>