本文整理汇总了PHP中Form_Button::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Form_Button::make方法的具体用法?PHP Form_Button::make怎么用?PHP Form_Button::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form_Button
的用法示例。
在下文中一共展示了Form_Button::make方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render the form as HTML
*/
public function render()
{
// Create the view
$this->layout($this->layout);
// Separate hidden and displayed fields
$fields = array();
$hidden = array();
// Are we using a twitter bootstrap layout?
$bootstrap = strrpos($this->layout->view, 'bootstrap') !== false;
// This is an extra iteration of the fields, but oh well
$this->assign_values();
foreach ($this->fields as $field) {
// Add bootstrap classes if appropriate
if ($bootstrap && $field->label) {
$field->label->add_class('control-label');
}
// Is it hidden?
// @todo: this prevents hidden fields from being
// usable inside multi-field, but I think that's okay
if ($field->is_hidden()) {
$hidden[] = $field;
} else {
if (!isset($field->label)) {
$field->label(ucwords(str_replace('_', ' ', $field->name)));
// Retroactively apply required class to label
if ($field->is_required()) {
$field->label->add_class('required');
}
}
$fields[] = $field;
}
}
// Make the buttons
$buttons = array();
if (!is_array($this->buttons)) {
$this->buttons = array();
} elseif (!count($this->buttons)) {
$this->buttons = array(Form_Button::make('Cancel')->attr('type', 'button')->attr('class', 'btn'), Form_Button::make('Submit')->attr('type', 'submit')->attr('class', 'btn btn-primary'));
}
foreach ($this->buttons as $key => $val) {
if (is_int($key) && is_array($val)) {
$buttons[] = Form_Button::make()->parse_config($val);
} elseif (is_int($key) && is_a($val, 'Squi\\Form_Button')) {
$buttons[] = $val;
} elseif (is_int($key)) {
$buttons[] = Form_Button::make($val)->attr('class', 'btn');
} elseif (is_string($key) && is_array($val)) {
$buttons[] = Form_Button::make($key)->parse_config($val);
} elseif (is_string($key) && is_string($val)) {
$buttons[] = Form_Button::make($key)->attr('name', $val)->attr('class', 'btn');
}
}
return $this->layout->with('form', $this)->with('fields', $fields)->with('hidden', $hidden)->with('buttons', $buttons)->render();
}