mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
working on form helper, added a submit button to form end if you pass true, added fieldset options to inputs
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4862 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
86d32e4313
commit
f4c9be8be2
1 changed files with 57 additions and 8 deletions
|
@ -104,12 +104,12 @@ class FormHelper extends AppHelper {
|
|||
if(!empty($object->validationErrors)) {
|
||||
$this->validationErrors[$model] = $object->validationErrors;
|
||||
}
|
||||
|
||||
|
||||
foreach($object->__associations as $type) {
|
||||
foreach($object->{$type} as $assoc => $value) {
|
||||
if (is_array($value) && isset($value['className']) && low($value['className']) !== low($object->name) && ClassRegistry::isKeySet($value['className'])) {
|
||||
$innerObject =& ClassRegistry::getObject($value['className']);
|
||||
|
||||
|
||||
if(!empty($innerObject->validationErrors)) {
|
||||
$this->validationErrors[$innerObject->name] = $innerObject->validationErrors;
|
||||
}
|
||||
|
@ -164,6 +164,9 @@ class FormHelper extends AppHelper {
|
|||
'action' => $options['action'],
|
||||
'id' => $id
|
||||
);
|
||||
if(!empty($options['action'])) {
|
||||
$options['id'] = $model . Inflector::camelize($options['action']) . 'Form';
|
||||
}
|
||||
$options['action'] = am($actionDefaults, (array)$options['url']);
|
||||
} elseif (is_string($options['url'])) {
|
||||
$options['action'] = $options['url'];
|
||||
|
@ -214,11 +217,40 @@ class FormHelper extends AppHelper {
|
|||
* @access public
|
||||
* @return string A closing FORM tag.
|
||||
*/
|
||||
function end($model = null) {
|
||||
if (empty($model) && !empty($this->params['models'])) {
|
||||
function end($options = null) {
|
||||
$out = null;
|
||||
if (!empty($this->params['models'])) {
|
||||
$models = $this->params['models'][0];
|
||||
}
|
||||
return $this->output($this->Html->tags['formend']);
|
||||
|
||||
$submitOptions = true;
|
||||
if(!is_array($options)) {
|
||||
$submitOptions = $options;
|
||||
} else if(isset($options['submit'])) {
|
||||
$submitOptions = $options['submit'];
|
||||
unset($options['submit']);
|
||||
|
||||
if(isset($submitOptions['label'])) {
|
||||
$submit = $submitOptions['label'];
|
||||
unset($submitOptions['label']);
|
||||
}
|
||||
}
|
||||
|
||||
if($submitOptions === true) {
|
||||
$submit = 'Submit';
|
||||
} else if(is_string($submitOptions)) {
|
||||
$submit = $submitOptions;
|
||||
}
|
||||
|
||||
if(!is_array($submitOptions)) {
|
||||
$submitOptions = array();
|
||||
}
|
||||
|
||||
if(isset($submit)) {
|
||||
$out .= $this->submit($submit, $submitOptions);
|
||||
}
|
||||
$out .= $this->Html->tags['formend'];
|
||||
return $this->output($out);
|
||||
}
|
||||
/**
|
||||
* Returns true if there is an error for the given field, otherwise false
|
||||
|
@ -299,6 +331,19 @@ class FormHelper extends AppHelper {
|
|||
* @return output
|
||||
*/
|
||||
function inputs($fields = null, $blacklist = null) {
|
||||
if(!is_array($fields)) {
|
||||
$fieldset = $fields;
|
||||
} else if(isset($fields['fieldset'])) {
|
||||
$fieldset = $fields['fieldset'];
|
||||
unset($fields['fieldset']);
|
||||
}
|
||||
|
||||
if($fieldset === true) {
|
||||
$legend = Inflector::humanize($this->action .' to '. $this->model());
|
||||
} else if(is_string($fieldset)){
|
||||
$legend = $fields;
|
||||
}
|
||||
|
||||
if(!is_array($fields)) {
|
||||
$fields = array_keys($this->fieldset['fields']);
|
||||
}
|
||||
|
@ -318,7 +363,11 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
$out .= $this->input($name, $options);
|
||||
}
|
||||
return $out;
|
||||
if(isset($legend)) {
|
||||
return sprintf($this->Html->tags['fieldset'], $legend, $out);
|
||||
} else {
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generates a form input element complete with label and wrapper div
|
||||
|
@ -893,9 +942,9 @@ class FormHelper extends AppHelper {
|
|||
${$selectAttrName} = $attributes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$attributes = am(array('minYear' => null, 'maxYear' => null), $attributes);
|
||||
|
||||
|
||||
switch($dateFormat) {
|
||||
case 'DMY': // so uses the new selex
|
||||
$opt = $this->day($tagName, $day, $selectDayAttr, $showEmpty) . '-' .
|
||||
|
|
Loading…
Add table
Reference in a new issue