Laraship

  1. Home
  2. Docs
  3. Laraship
  4. Customize Laraship
  5. Crud Builder

Crud Builder

Laraship makes it really easy to create form components inside your Form, Using CoralsForms class, it supports almost all form components even the advanced ones, makes it the most powerful laravel CRUD Builder.

below is a usage examples for some of the main form components.

 

Text Field:

Usage:

text($key, $label = '', $required = false, $value = null, $attributes = [])

Example:

{!! CoralsForm::text('phone_country_code', 'User::attributes.user.phone_country_code' ,false,null,['id'=>'authy-countries']) !!}

DropDown with select2 library support

Usage:

public function select($key, $label = '', $options = [], $required = false, $value = null, $attributes = [], $type = 'select')

Examples:

  • Tags with Multiple Select:
{!! CoralsForm::select('tags[]','Classified::attributes.product.tags', \Tag::getTagsList('Classified'),false,null,['class'=>'tags', 'multiple'=>true], 'select2') !!}
  • Select with Ajax Data Sources
{!! CoralsForm::select("extras[bcc_users][]",  'Notification::attributes.notification_template.bcc_users' , [], false, $notification_template->extras['bcc_users']??[],
 ['multiple', 'help_text' => 'Notification::attributes.notification_template.bcc_users_help',
 'class'=>'select2-ajax',
 'data'=>[
        'model'=>\Corals\User\Models\User::class,
        'columns'=> json_encode(['name', 'email']),
        'selected'=>json_encode($notification_template->extras['bcc_users']??[]),
        'where'=>json_encode([]),]
        ], 'select2') !!}
  • Select From Settings Values
{!! CoralsForm::select('classification','User::attributes.user.classification', \Settings::get('customer_classifications',[])) !!}

 

Text Area:

Usage:

public function textarea($key, $label = '', $required = false, $value = null, $attributes = [])

 

Examples:

  • Default:
{!! CoralsForm::textarea('description','Menu::attributes.menu.description',false,$menu->description,['rows'=>3]) !!}
  • CKEditor
{!! CoralsForm::textarea('description','Classified::attributes.product.description',false, $product->description, ['class'=>'ckeditor','rows'=>5]) !!}

 

Checkbox:

Usage:

public function checkbox($key, $label = '', $checked = false, $value = 1, $attributes = [])

Example

  • Default
{!! CoralsForm::checkbox('is_featured', 'Classified::attributes.product.is_featured', $product->is_featured) !!}

 

Radio Button:

Usage:

public function radio($key, $label = '', $required = false, $options, $selected = null, $attributes = [])

Example

  • Default:
{!! CoralsForm::radio('status','Corals::attributes.status', true, trans('Corals::attributes.status_options')) !!}

 

Open Form:

Example

  • Pass Model
{!! CoralsForm::openForm($product) !!}
  • Without Model:
{!! CoralsForm::openForm(null,['url' => url('amazon/settings/'.$store->hashed_id),'method'=>'POST']) !!}

Close Form:

Example:

  • Pass Model
{!! CoralsForm::closeForm($product) !!}
  • Without Model:
{!! CoralsForm::closeForm() !!}

 

Link:

Usage:

public function link($href, $label, $attributes = [])

Example:

{!! CoralsForm::link(url($resource_url.'/'.$subscription->hashed_id.'/create-invoice'),'Subscriptions::labels.subscription.create_invoice_label',['class'=>'btn btn-primary']) !!}

 

Password:

Usage:

public function password($key, $label = '', $required = false, $attributes = [])

Example

{!! CoralsForm::password('password','User::attributes.user.password') !!}

 

Form Buttons

Add Save & Cancel to Crud Form

Usage:

{!! CoralsForm::formButtons() !!}

 

Button:

Usage:

public function button($label, $attributes = [], $type = 'button')

Example

{!! CoralsForm::button('corals-ecommerce-basic::labels.partial.add_to_cart',
['class'=>'btn add-to-cart btn-sm btn-primary'], 'submit') !!}

 

Custom Fields:

Show custom fields for the specific object in the form

Example

{!! CoralsForm::customFields($product) !!}

 

It worth mentioning that Laraship Laravel Crud builder supports both Bootstrap 4 and Bootstrap 3, and it handles the bootstrap structure like form group element and it produces a complete bootstrap element with the group, label, and the input.

Happy New Year!

40% DISCOUNT ON OUR ENTIRE STORE
COUPON CODE : Hello2021
GO TO STORE
LIMITED TIME OFFER
close-link
40% Off on all of LARASHIP platforms, plugins, and themes NO EXCLUSIONS
CODE: Hello2021
close-image