本文整理汇总了PHP中MY_Model::form_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP MY_Model::form_fields方法的具体用法?PHP MY_Model::form_fields怎么用?PHP MY_Model::form_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MY_Model
的用法示例。
在下文中一共展示了MY_Model::form_fields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Add FUEL specific changes to the form_fields method
*
* @access public
* @param string
* @param int
* @return boolean
*/
function form_fields($values = array(), $related = array())
{
$fields = parent::form_fields($values, $related);
$order = 1;
// create default images
$upload_path = assets_server_path('', 'images');
$order = 1;
foreach ($fields as $key => $field) {
$fields[$key]['order'] = $order;
// get field names that end with _image
if ($fields[$key]['type'] == 'string' and substr($key, -5) == 'image' or substr($key, -3) == 'img') {
$img = '';
if (!empty($values['id'])) {
if (!empty($values[$key])) {
$img = '<div class="img_display"><img src="' . img_path($values[$key]) . '" style="float: right;"/></div>';
}
}
$fields[$key]['class'] = 'asset_select';
$order++;
$fields[$key . '_upload'] = array('order' => $order, 'before_html' => $img, 'label' => '... OR upload an image', 'upload_path' => $upload_path, 'type' => 'file', 'overwrite' => TRUE);
}
$order++;
}
$yes = lang('form_enum_option_yes');
$no = lang('form_enum_option_no');
if (isset($fields['published'])) {
$fields['published']['order'] = 9999;
$fields['published']['options'] = array('yes' => $yes, 'no' => $no);
}
if (isset($fields['active'])) {
$fields['active']['order'] = 9999;
$fields['active']['options'] = array('yes' => $yes, 'no' => $no);
}
return $fields;
}
示例2: form_fields
/**
* Add FUEL specific changes to the form_fields method
*
* @access public
* @param array Values of the form fields (optional)
* @param array An array of related fields. This has been deprecated in favor of using has_many and belongs to relationships (deprecated)
* @return array An array to be used with the Form_builder class
*/
public function form_fields($values = array(), $related = array())
{
$fields = parent::form_fields($values, $related);
$order = 1;
// create default images
$upload_path = assets_server_path('', 'images');
$order = 1;
foreach ($fields as $key => $field) {
$fields[$key]['order'] = $order;
$order++;
}
$yes = lang('form_enum_option_yes');
$no = lang('form_enum_option_no');
if (isset($fields['published'])) {
$fields['published']['order'] = 9999;
$fields['published']['options'] = array('yes' => $yes, 'no' => $no);
}
if (isset($fields['active'])) {
$fields['active']['order'] = 9999;
$fields['active']['options'] = array('yes' => $yes, 'no' => $no);
}
return $fields;
}
示例3: form_fields
/**
* Add FUEL specific changes to the form_fields method
*
* @access public
* @param array Values of the form fields (optional)
* @param array An array of related fields. This has been deprecated in favor of using has_many and belongs to relationships (deprecated)
* @return array An array to be used with the Form_builder class
*/
public function form_fields($values = array(), $related = array())
{
$fields = parent::form_fields($values, $related);
// $order = 1;
// foreach($fields as $key => $field)
// {
// $fields[$key]['order'] = $order;
// $order++;
// }
$yes = lang('form_enum_option_yes');
$no = lang('form_enum_option_no');
if (isset($fields['published'])) {
$fields['published']['order'] = 9999;
$fields['published']['options'] = array('yes' => $yes, 'no' => $no);
}
if (isset($fields['active'])) {
$fields['active']['order'] = 9999;
$fields['active']['options'] = array('yes' => $yes, 'no' => $no);
}
if (!empty($this->form_fields_class) and class_exists($this->form_fields_class)) {
$fields = new $this->form_fields_class($fields, $values, $this);
}
return $fields;
}