cakephp2-php8/cake/libs/view/helpers/form.php

470 lines
18 KiB
PHP
Raw Normal View History

<?php
/* SVN FILE: $Id$ */
/**
* Automatic generation of HTML FORMs from given data.
*
* Used for scaffolding.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
* Copyright (c) 2005, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
* @subpackage cake.cake.libs.view.helpers
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Tag template for a div.
*/
define('TAG_DIV', '<div class="%s">%s</div>');
/**
* Tag template for a div.
*/
define('TAG_P_CLASS', '<p class="%s">%s</p>');
/**
* Tag template for a label.
*/
define('TAG_LABEL', '<label for="%s">%s</label>');
/**
* Tag template for a fieldset.
*/
define('TAG_FIELDSET', '<fieldset><legend>%s</legend>%s</label>');
/**
* Form helper library.
*
* Automatic generation of HTML FORMs from given data.
*
* @package cake
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
* @subpackage cake.cake.libs.view.helpers
* @since CakePHP v 0.10.0.1076
*
*/
class FormHelper extends Helper
{
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
var $helpers = array('Html');
/**
* Constructor which takes an instance of the HtmlHelper class.
*
* @param object $htmlHelper the HtmlHelper object to use as our helper.
* @return void
*/
function FormHelper()
{
}
/**
* Returns a formatted error message for given FORM field, NULL if no errors.
*
* @param string $field If field is to be used for CRUD, this should be modelName/fieldName
* @return bool If there are errors this method returns true, else false.
*/
function isFieldError($field )
{
$error = 1;
$this->Html->setFormTag( $field );
if( $error == $this->Html->tagIsInvalid( $this->Html->model, $this->Html->field) )
{
return true;
} else {
return false;
}
}
/**
* Returns a formatted LABEL element for HTML FORMs.
*
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $text Text that will appear in the label field.
* @return string The formatted LABEL element
*/
function labelTag( $tagName, $text )
{
return sprintf( TAG_LABEL, strtolower(str_replace('/', '_',$tagName)), $text );
}
/**
* Returns a formatted DIV tag for HTML FORMs.
*
* @param string $class If field is to be used for CRUD, this should be modelName/fieldName
* @param string $text Text that will appear in the label field.
* @return string The formatted DIV element
*/
function divTag( $class, $text )
{
return sprintf( TAG_DIV, $class, $text );
}
/**
* Returns a formatted P tag with class for HTML FORMs.
*
* @param string $class If field is to be used for CRUD, this should be modelName/fieldName
* @param string $text Text that will appear in the label field.
* @return string The formatted DIV element
*/
function pTag( $class, $text )
{
return sprintf( TAG_P_CLASS, $class, $text );
}
/**
* Returns a formatted INPUT tag for HTML FORMs.
*
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $prompt Text that will appear in the label field.
* @param bool $required True if this field is required.
* @param string $errorMsg Text that will appear if an error has occurred.
* @param int $size Size attribute for INPUT element
* @param array $htmlOptions
* @return string The formatted INPUT element
*/
function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null )
{
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->inputTag( $tagName, $size, $htmlOptions );
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
$divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
return $this->divTag( $divClass, $divTagInside );
}
/**
* Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs.
*
* @param HtmlHelper $html The HtmlHelper object which is creating this form.
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $prompt Text that will appear in the label field.
* @param bool $required True if this field is required.
* @param string $errorMsg Text that will appear if an error has occurred.
* @param int $size Size attribute for INPUT element
* @param array $htmlOptions
* @return string The formatted INPUT element
*/
function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null )
{
$htmlOptions['class'] = "inputCheckbox";
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->checkbox( $tagName, null, $htmlOptions );
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
$divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
return $this->divTag( $divClass, $divTagInside );
}
/**
* Returns a formatted date option element for HTML FORMs.
*
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $prompt Text that will appear in the label field.
* @param bool $required True if this field is required.
* @param string $errorMsg Text that will appear if an error has occurred.
* @param int $size Size attribute for INPUT element
* @param array $htmlOptions
* @return string The formatted INPUT element
*/
function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected )
{
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE', '', $selected, $htmlOptions);
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
$divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
$requiredDiv = $this->divTag( $divClass, $divTagInside );
return $this->divTag("date", $requiredDiv);
}
/**
* Returns a formatted datetime option element for HTML FORMs.
*
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $prompt Text that will appear in the label field.
* @param bool $required True if this field is required.
* @param string $errorMsg Text that will appear if an error has occurred.
* @param int $size Size attribute for INPUT element
* @param array $htmlOptions
* @return string The formatted datetime option element
*/
function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null )
{
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , '12', $selected, $htmlOptions);
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
$divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
$requiredDiv = $this->divTag( $divClass, $divTagInside );
return $this->divTag("date", $requiredDiv);
}
/**
* Returns a formatted TEXTAREA inside a DIV for use with HTML forms.
*
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $prompt Text that will appear in the label field.
* @param boolean $required True if this field is required.
* @param string $errorMsg ext that will appear if an error has occurred.
* @param integer $cols Number of columns.
* @param integer $rows Number of rows.
* @param array $htmlOptions
* @return string The formatted TEXTAREA element
*/
function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null )
{
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->areaTag( $tagName, $cols, $rows, $htmlOptions );
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
$divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
return $this->divTag( $divClass, $divTagInside );
}
/**
* Returns a formatted SELECT tag for HTML FORMs.
*
* @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName
* @param string $prompt Text that will appear in the label field
* @param array $options Options to be contained in SELECT element
* @param string $selected Text of the currently selected item
* @param array $selectAttr Array of HTML attributes for the SELECT element
* @param array $optionAttr Array of HTML attributes for the OPTION elements
* @param bool $required True if this field is required
* @param string $errorMsg Text that will appear if an error has occurred
* @return string The formatted INPUT element
*/
function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null)
{
$selectAttr['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr );
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
$divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
return $this->divTag( $divClass, $divTagInside );
}
/**
* Returns a formatted submit widget for HTML FORMs.
*
* @param string $prompt Text that will appear on the widget
* @param array $htmlOptions
* @return string The formatted submit widget
*/
function generateSubmitDiv($displayText, $htmlOptions = null)
{
return $this->divTag( 'submit', $this->Html->submitTag( $displayText, $htmlOptions) );
}
/**
* Generates a form to go onto a HtmlHelper object.
*
* @param array $fields An array of form field definitions
* @param boolean $readOnly True if the form should be rendered as READONLY
* @return string The completed form specified by the $fields parameter
*/
function generateFields( $fields, $readOnly = false )
{
$strFormFields = '';
foreach( $fields as $field )
{
if( isset( $field['type'] ) )
{
// initialize some optional parameters to avoid the notices
if( !isset($field['required'] ) )
$field['required'] = false;
if( !isset( $field['errorMsg'] ) )
$field['errorMsg'] = null;
if( !isset( $field['htmlOptions'] ) )
$field['htmlOptions'] = array();
if( $readOnly )
{
$field['htmlOptions']['READONLY'] = "readonly";
}
switch( $field['type'] )
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
{
case "input" :
// If the size has not been set, initialize it to 40.
if( !isset( $field['size'] ) )
{
$field['size'] = 40;
}
$strFormFields = $strFormFields.$this->generateInputDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] );
break;
case "checkbox" :
$strFormFields = $strFormFields.$this->generateCheckboxDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] );
break;
case "select";
case "selectMultiple";
{
if( "selectMultiple" == $field['type'] )
{
$field['selectAttr']['multiple'] = 'multiple';
$field['selectAttr']['class'] = 'selectMultiple';
}
// If the selected attribute has not been set, initialize it to null.
if( !isset( $field['selected'] ) )
$field['selected'] = null;
if( !isset( $field['selectAttr'] ) )
$field['selectAttr'] = null;
if( !isset( $field['optionsAttr'] ) )
$field['optionsAttr'] = null;
if( $readOnly )
$field['selectAttr']['DISABLED'] = true;
$strFormFields = $strFormFields.$this->generateSelectDiv( $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] );
}
break;
case "area";
{
if( !isset( $field['rows'] ) )
$field['rows'] = 10;
if( !isset( $field['cols'] ) )
$field['cols'] = 60;
$strFormFields = $strFormFields.$this->generateAreaDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] );
}
break;
case "fieldset";
$strFieldsetFields = $this->generateFields( $field['fields'] );
$strFieldSet = sprintf( '
<fieldset>
<legend>%s</legend>
<div class="notes">
<h4>%s</h4>
<p class="last">%s</p>
</div>
%s
</fieldset>', $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields );
$strFormFields = $strFormFields.$strFieldSet;
break;
case "hidden";
$strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']);
break;
case "date":
$strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'], null, null, null, null, $field['selected']);
break;
case "datetime":
$strFormFields = $strFormFields.$this->generateDateTime( $field['tagName'], $field['prompt'], '','','', '', $field['selected']);
break;
default:
//bugbug: i don't know how to put out a notice that an unknown type was entered.
break;
} // end switch $field['type']
} // end if isset $field['type']
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
}
return $strFormFields;
}
}
?>