This is a custom form layout example. It provide functionality to modify form layout according to the Bootstrap format. In this example I modify layout into 2 rows, first row contain title and category and second row contain description.

	$categoryList= $this->getCategoryList();
	$Scaffolding= new Scaffolding("posts");
	$Scaffolding->join('categories', 'categories.id', '=', 'posts.category', 'INNER');
	$Scaffolding->setFormInputFiller("category", $categoryList);
	// Set columns properties
	$parameters= array(
	    array(
	    	'name'=>'no',
	    	'width'=>'1%',
	    ),
	    array(
	    	'name'=>'categories.name',
	    	'label'=>'Category',
	    	'width'=>'30%',
	    ),
	    array(
	    	'name'=>'title',
	    	'width'=>'49%',
	    ),
	    array(
	    	'name'=>'actions',
	    	'width'=>'20%',
	    ),
	);
	$Scaffolding->setColumnProperties($parameters);
	// Modify form layout
	$Scaffolding->addHooks("modifyLayout", array($this, "modifyFormLayout"));
	$content= $Scaffolding->render();
	$parameters= array(
		'scaffolding'=>$content
	);
	return view('demo', $parameters);
	

This is callback for modify form layout.

    /**
	* Modify form layout
	* 
	* @param  array $layout
	* 
	* @return  array
	*/
    public function modifyFormLayout($layout)
    {
    	$newLayout= array();
    	$newLayout[]= array(
	    	array(
				'attributes' => array(
					'class' => 'col-sm-6',
				),
				'name' => 'title',
			),
	    	array(
				'attributes' => array(
					'class' => 'col-sm-6',
				),
				'name' => 'category',
			),
		);
    	$newLayout[]= array(
	    	array(
				'attributes' => array(
					'class' => 'col-sm-12',
				),
				'name' => 'description',
			),
		);
    	return $newLayout;
    }
	
Cancel