Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions View/Helper/NetCommonsFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @package NetCommons\NetCommons\View\Helper
*/
class NetCommonsFormHelper extends FormHelper {
class NetCommonsFormHelper extends Helper {

/**
* Other helpers used by FormHelper
Expand Down Expand Up @@ -56,10 +56,10 @@ class NetCommonsFormHelper extends FormHelper {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-create
*/
public function create($model = null, $options = array()) {
if (! isset($options['ng-submit'])) {
if (!isset($options['ng-submit'])) {
$options['ng-submit'] = 'sending=true;';
}
if (! isset($options['novalidate'])) {
if (!isset($options['novalidate'])) {
$options['novalidate'] = true;
}
return $this->Form->create($model, $options);
Expand All @@ -79,7 +79,7 @@ public function create($model = null, $options = array()) {
* - `type` - Force the type of widget you want. e.g. `type => 'select'`
* - `label` - Either a string label, or an array of options for the label. See FormHelper::label().
* - `div` - Either `false` to disable the div, or an array of options for the div.
* See HtmlHelper::div() for more options.
* See HtmlHelper::div() for more options.
* - `options` - For widgets that take options e.g. radio, select.
* - `error` - Control the error message that is produced. Set to `false` to disable any kind of error reporting (field
* error and error messages).
Expand All @@ -89,10 +89,10 @@ public function create($model = null, $options = array()) {
* - `after` - Content to place after the label + input.
* - `between` - Content to place between the label + input.
* - `format` - Format template for element order. Any element that is not in the array, will not be in the output.
* - Default input format order: array('before', 'label', 'between', 'input', 'after', 'error')
* - Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error')
* - Hidden input will not be formatted
* - Radio buttons cannot have the order of input and label elements controlled with these settings.
* - Default input format order: array('before', 'label', 'between', 'input', 'after', 'error')
* - Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error')
* - Hidden input will not be formatted
* - Radio buttons cannot have the order of input and label elements controlled with these settings.
*
* @param string $fieldName This should be "Modelname.fieldname"
* @param array $options Each type of input takes different options.
Expand Down Expand Up @@ -123,19 +123,19 @@ public function input($fieldName, $options = array()) {

$output = '';

if (! isset($inputOptions['div'])) {
if (!isset($inputOptions['div'])) {
$output .= '<div class="form-group">';
}

$output .= $this->Form->input($fieldName, $inputOptions);

if (! isset($options['error']) || $options['error']) {
if (!isset($options['error']) || $options['error']) {
$output .= '<div class="has-error">';
$output .= $this->Form->error($fieldName, null, array('class' => 'help-block'));
$output .= '</div>';
}

if (! isset($inputOptions['div'])) {
if (!isset($inputOptions['div'])) {
$output .= '</div>';
}

Expand Down Expand Up @@ -228,7 +228,7 @@ public function inlineCheckbox($fieldName, $attributes = array()) {
$output = '<div class="form-group">';
$output .= $this->Form->input($fieldName, $inputAttributes);

if (! isset($attributes['error']) || $attributes['error']) {
if (!isset($attributes['error']) || $attributes['error']) {
$output .= '<div class="has-error">';
$output .= $this->Form->error($fieldName, null, array('class' => 'help-block'));
$output .= '</div>';
Expand Down Expand Up @@ -262,4 +262,14 @@ public function wysiwyg($fieldName, $attributes = array()) {
return $this->input($fieldName, $attributes);
}

}
/**
* FormHelperラップ用マジックメソッド。
*
* @param string $method メソッド
* @param array $params パラメータ
* @return mixed
*/
public function __call($method, $params) {
return call_user_func_array(array(& $this->Form, $method), $params);
}
}