1. Go to this page and download the library: Download jonob/formly library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Standard Laravel form input
Form::text($name, $value, $attributes);
// Formly
$form->text($name, $label, $value, $attributes);
$form->open();
// Get the single post from the post model
$post::find($post_id);
// Pass the default values to Formly
$form = Formly::make($post);
// Create the view
return View::make('posts.form')->with('form', $form);
// Pass the default values to Formly
$form = Formly::make(array('start_date' => date('Y-m-d')));
// Create the view
return View::make('posts.form')->with('form', $form);
// Controller
public function edit($id)
{
$post = Post::find($id);
if ( ! $post) {
// do something. Maybe redirect or 404?
}
return View::make('posts.form')
->with('form', Formly::make($post));
}
public function update()
{
$rules = array(
'name' => 'eturn Redirect::to('posts');
}
$form->submit('Save');
$form->submit('Save', $attributes, 'some-class');
// create a button with a class of 'btn btn-primary'
$form->submitPrimary('Save');
// and so on...
$form->submitInfo('Save');
$form->submitSuccess('Save');
$form->submitWarning('Save');
$form->submitDanger('Save');
$form->submitInverse('Save');
$defaults = Post::find($id);
$options = array(
'formClass' => 'form_vertical'
);
// Set multiple options when the class is instantiated
$form = Formly::make($defaults, $options);
// Set multiple options using setOption()
$form = Formly::make()->setOption($options);
// Set a single option using setOption()
$form = Formly::make()->setOption('formClass', 'form_vertical');
$form->text('start_date', 'Start Date.req');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.