Simplify and clarify Forms and FormViews #54
@ -122,7 +122,7 @@ class EditAlbum extends HTMLController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		$this->form = new Form([
 | 
							$this->form = new Form([
 | 
				
			||||||
			'request_url' => BASEURL . '/editalbum/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
 | 
								'request_url' => BASEURL . '/editalbum/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
 | 
				
			||||||
			'content_below' => $after_form,
 | 
								'buttons_extra' => $after_form,
 | 
				
			||||||
			'fields' => $fields,
 | 
								'fields' => $fields,
 | 
				
			||||||
		]);
 | 
							]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -106,7 +106,7 @@ class EditTag extends HTMLController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		$form = new Form([
 | 
							$form = new Form([
 | 
				
			||||||
			'request_url' => BASEURL . '/edittag/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
 | 
								'request_url' => BASEURL . '/edittag/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
 | 
				
			||||||
			'content_below' => $after_form,
 | 
								'buttons_extra' => $after_form,
 | 
				
			||||||
			'fields' => $fields,
 | 
								'fields' => $fields,
 | 
				
			||||||
		]);
 | 
							]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -69,7 +69,7 @@ class EditUser extends HTMLController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		$form = new Form([
 | 
							$form = new Form([
 | 
				
			||||||
			'request_url' => BASEURL . '/edituser/?' . ($id_user ? 'id=' . $id_user : 'add'),
 | 
								'request_url' => BASEURL . '/edituser/?' . ($id_user ? 'id=' . $id_user : 'add'),
 | 
				
			||||||
			'content_below' => $after_form,
 | 
								'buttons_extra' => $after_form,
 | 
				
			||||||
			'fields' => [
 | 
								'fields' => [
 | 
				
			||||||
				'first_name' => [
 | 
									'first_name' => [
 | 
				
			||||||
					'type' => 'text',
 | 
										'type' => 'text',
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ class Form
 | 
				
			|||||||
	public $request_method;
 | 
						public $request_method;
 | 
				
			||||||
	public $request_url;
 | 
						public $request_url;
 | 
				
			||||||
	public $content_above;
 | 
						public $content_above;
 | 
				
			||||||
	public $content_below;
 | 
						public $buttons_extra;
 | 
				
			||||||
	private $fields = [];
 | 
						private $fields = [];
 | 
				
			||||||
	private $data = [];
 | 
						private $data = [];
 | 
				
			||||||
	private $missing = [];
 | 
						private $missing = [];
 | 
				
			||||||
@ -24,7 +24,7 @@ class Form
 | 
				
			|||||||
		$this->request_method = !empty($options['request_method']) ? $options['request_method'] : 'POST';
 | 
							$this->request_method = !empty($options['request_method']) ? $options['request_method'] : 'POST';
 | 
				
			||||||
		$this->request_url = !empty($options['request_url']) ? $options['request_url'] : BASEURL;
 | 
							$this->request_url = !empty($options['request_url']) ? $options['request_url'] : BASEURL;
 | 
				
			||||||
		$this->fields = !empty($options['fields']) ? $options['fields'] : [];
 | 
							$this->fields = !empty($options['fields']) ? $options['fields'] : [];
 | 
				
			||||||
		$this->content_below = !empty($options['content_below']) ? $options['content_below'] : null;
 | 
							$this->buttons_extra = !empty($options['buttons_extra']) ? $options['buttons_extra'] : null;
 | 
				
			||||||
		$this->content_above = !empty($options['content_above']) ? $options['content_above'] : null;
 | 
							$this->content_above = !empty($options['content_above']) ? $options['content_above'] : null;
 | 
				
			||||||
		$this->submit_caption = !empty($options['submit_caption']) ? $options['submit_caption'] : 'Save information';
 | 
							$this->submit_caption = !empty($options['submit_caption']) ? $options['submit_caption'] : 'Save information';
 | 
				
			||||||
		$this->trim_inputs = !empty($options['trim_inputs']);
 | 
							$this->trim_inputs = !empty($options['trim_inputs']);
 | 
				
			||||||
 | 
				
			|||||||
@ -48,9 +48,9 @@ class FormView extends SubTemplate
 | 
				
			|||||||
					<div class="offset-sm-2 col-sm-10">
 | 
										<div class="offset-sm-2 col-sm-10">
 | 
				
			||||||
						<button type="submit" name="submit" class="btn btn-primary">', $this->form->getSubmitButtonCaption(), '</button>';
 | 
											<button type="submit" name="submit" class="btn btn-primary">', $this->form->getSubmitButtonCaption(), '</button>';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (isset($this->form->content_below))
 | 
							if (isset($this->form->buttons_extra))
 | 
				
			||||||
			echo '
 | 
								echo '
 | 
				
			||||||
						', $this->form->content_below;
 | 
											', $this->form->buttons_extra;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		echo '
 | 
							echo '
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user