class baseformgroup
public function media_form_group_box($medias, $label, $icon, $field, $helper, $required)
/*** 輸入型表單
*/public function text_input_field($name, $module, $label, $value)
/*** textarea表單
*/public function textarea_input_field($name, $module, $label, $value)
public function editor_input_field($name, $module, $label, $value)
/*** **型表單
*/public function number_input_field($name, $module, $label, $value)
/*** **型表單
*/public function file_input_field($name, $module, $label, $value)
/*** **型表單
*/public function multiple_file_input_field($name, $module, $label, $value)
/*** 下拉表單
*/public function select_field($name, $module, $value, $data) else
}$field = ''. $options .'';
return $field;
}/**
* radio表單
*/public function radio_field($name, $module, $value, $data)
$field .= ''. $val . '';
}$field .= '
'; return $field;
}/**
* 表單label
*/private function form_label_box($label, $required = false)
return ''. $label .'';
}/**
* 表單域
*/private function form_input_box($field, $icon = '')
return ''.$form_icon . $field . '
'; }
/*** 表單提示內容
*/private function form_helper_box($helper)
return $form_helper;
}/**
*/private function form_media_box($medias)
return $html;
}/**
* 如果名稱在模型中,則id表示為module_name, name表示為module[name]
* 如article的title欄位, id = article_title, name = article[name]
*/private function get_input_module($name, $module = '')
return ['id' => $id_value, 'name' => $name_value];
}} class myform extends baseformgroup
/*** textarea輸入框
*/public function textarea_field($label, $name, $value = '', $module = '', $required = false, $helper = '')
/*** 手機輸入框
*/public function phone_field($label, $name, $value = '', $module = '', $required = false, $helper = '')
/*** 數字輸入框
*/public function number_filed($label, $name, $value = '', $module = '', $required = false, $helper = '')
/*** email輸入框
*/public function email_filed($label, $name, $value = '', $module = '', $required = false, $helper = '')
/*** 超連結輸入框
*/public function url_filed($label, $name, $value = '', $module = '', $required = false, $helper = '')
/*** 編輯器
*/public function editor_filed($label, $name, $value = '', $module = '', $required = false, $helper = '')
/*** 上傳
*/public function image_field($label, $name, $value = '', $module = '', $required = false, $helper = '')
$field = $this->file_input_field($name, $module, $label, $value);
$html = $this->media_form_group_box($medias, $label, $icon, $field, $helper, $required);
echo $html;
}/**
*/public function video_field($label, $name, $value = '', $module = '', $required = false, $helper = '')
$field = $this->file_input_field($name, $module, $label, $value);
$html = $this->media_form_group_box($medias, $label, $icon, $field, $helper, $required);
echo $html;
}/**
* 多圖上傳
*/public function multiple_field($label, $name, $value = , $module = '', $required = false, $helper = '')
}$field = $this->multiple_file_input_field($name, $module, $label, $value);
$html = $this->media_form_group_box($medias, $label, $icon, $field, $helper, $required);
echo $html;
}/**
* 下拉列表
*/public function select_list($label, $name, array $data, $value = '', $module = '', $required = false, $helper = '')
/*** 單選
*/public function radio_list($label, $name, array $data, $value = '', $module = '', $required = false, $helper = '') }
laravel表單驗證
效果展示 實現 後台 use validator php view plain copy print public function login 使用者驗證 user db table user select user id user encrypt user pwd where user name...
Laravel的表單驗證
修改密碼 如果要驗證的字段是password,輸入中必須存在匹配的password confirmation字段。驗證的字段值必須與引數欄位的值不同。public function rules 驗證陣列 通常我們的前端通常會寫成這個樣子 然後在後端可以通過多對多的關聯來實現這個新增標籤的功能,但是其...
Laravel使用記錄(十)表單驗證(三)
語言包 乙個表單我們可以這麼設定,兩個表單我們還能這麼設定,但是如果乙個專案十個八個表單,同樣的東西我們豈不是要設定幾百遍?難道沒有更加簡單的方法?答案是肯定的,有,使用語言包。語言包的位置在resources lang資料夾下,預設有乙個語言包en,我們可以看到en下面有四個檔案,分別是許可權 a...