This is a custom validation example. It provide functionality to modify validation rules using Hook Filter insertModifyValidationRules. In this example I add exist validation rule to check category is valid. You can select Fakel category then click save button to trigger the error.

	$categoryList= $this->getCategoryListFake();
	$Scaffolding= new Scaffolding("posts");
	$Scaffolding->join('categories', 'categories.id', '=', 'posts.category', 'INNER');
	// Define form input filler for category
	$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 validation rules
	$Scaffolding->addHooks("insertModifyValidationRules", 
	array($this, "modifyCategoryValidation"));
	$content= $Scaffolding->render();
	$parameters= array(
		'scaffolding'=>$content
	);
	return view('demo', $parameters);
	

This is callback for modify validation rules.

    /**
	* Modify category validation
	* 
	* @param  array $rules
	* 
	* @return  array
	*/
    public function modifyCategoryValidation($rules)
    {
    	$rules['category'].= '|exists:categories,id';
    	return $rules;
    }
	
Cancel