Skrypt wygląda tak
Kod: Zaznacz cały
*/
class Form_Frontend_Posts_Add extends Bform_Form {
public function create(array $params = array())
{
$this->param('i18n_namespace', 'posts.forms');
$categories = Model_Post_Category::factory()->get_for_select();
$this->add_select('category_id', Arr::unshift($categories, NULL, ___('select.choose')));
$this->add_input_text('title', array())
->add_validator('title', 'Bform_Validator_HTML')
->add_validator('title', 'Bform_Validator_Length', array('max' => 64));
$this->add_textarea('description_short', array('chars_counter' => 200))
->add_validator('description_short', 'Bform_Validator_HTML')
->add_validator('description_short', 'Bform_Validator_Length', array('max' => 200));
$this->add_editor('content', array(
'editor_type' => Bform_Driver_Editor::TYPE_SIMPLE,
))
->add_filter('content', 'Bform_Filter_CleanHTML', array('config' => array(
'HTML.Allowed' => 'b,em,ul,li,ol,p,span[style],br,div,br,strong',
)));
$this->add_input_text('author', array('required' => FALSE))
->add_validator('author', 'Bform_Validator_HTML');
$this->add_input_text('source', array('required' => FALSE))
->add_validator('source', 'Bform_Validator_HTML');
$this->add_input_text('keywords', array('required' => FALSE))
->add_validator('keywords', 'Bform_Validator_HTML');
if(Posts::config('big_slider_enabled'))
{
$img_config = img::type_config('post_big_slider');
$this->add_input_file('image_big_slider', array('required' => FALSE, 'html_before' => ___('posts.forms.image_size_info', array(
':width' => Arr::get($img_config, 'width'),
':height' => Arr::get($img_config, 'height'),
))))
->add_validator('image_big_slider', 'Bform_Validator_File_Filesize')
->add_validator('image_big_slider', 'Bform_Validator_File_Image');
}
$img_config = img::type_config('post_slider');
$this->add_input_file('image_lead', array('required' => FALSE, 'html_before' => ___('posts.forms.image_size_info', array(
':width' => Arr::get($img_config, 'width'),
':height' => Arr::get($img_config, 'height'),
))))
->add_validator('image_lead', 'Bform_Validator_File_Filesize')
->add_validator('image_lead', 'Bform_Validator_File_Image');
$this->add_file_uploader('gallery', array('amount' => 10, 'required' => FALSE));
$this->add_input_email('email', array('required' => FALSE));
$this->add_input_submit(___('form.save'));
}
}