Giter Club home page Giter Club logo

orchid-repeater-field's Introduction

Orchid Platform Repeater Field

Orchid Platform Repeater Field

Brief

This package adding repeater fields support to Orchid RAD platform.

Pre-requirements

You must have installed and configured Orchid Platform

Version Support: .*

For 6.* version use 2.0.5 tag

For 5 version use 1.0.0 tag.

For 4.7.1 version use 0.0.8 tag.

How to use

  1. Install package with composer: composer require nakukryskin/orchid-repeater-field

    Latest version of laravel automatically discover package to use.

  2. Create RepeaterFields.php in your Orchid Layouts directory. Example:

    <?php
    
    namespace App\Http\Orchid\Layouts\Repeaters;
    
    use Orchid\Screen\Layouts\Rows;
    use Orchid\Screen\Fields\Input;
    use Orchid\Screen\Fields\Select;
    
    class RepeaterFields extends Rows
    {
    
        /**
         * Return array of the fields
         *
         * @return array
         */
        function fields(): array
        {
            return [
                Input::make('repeater_name')
                    ->type('text')
                    ->max(255)
                    ->required()
                    ->title('Nested Field'),
                //Multiple fields must ends with the dot 
                Select::make('select.')
                             ->multiple()
                             ->options([
                                 'test' => 'Test',
                                 'test2' => 'Test2'
                             ])
                             ->required()
            ];
        }
    }
  3. Simply start adding the RepeaterField::make('repeater') in your screen: Example:

        public function layout(): array
        {
            return [
                Layout::rows([
                    RepeaterField::make('repeater')
                        ->title('Repeater')
                        ->layout(App\Http\Orchid\Layouts\Repeaters\RepeaterFields::class),
                ])
            ];
        }
  4. Open your screen and check that the repeater fields here

Advanced usage

Repeater field also support required, max and min parameters. You can add these parameters with call the RepeaterField.

RepeaterField::make('repeater')
    ->title('Repeater')
    ->layout(App\Http\Orchid\Layouts\Repeaters\RepeaterFields::class)
    ->required()
    ->min(10)
    ->max(20)

If required() passed to the constructor min() automatically will set to 1. If user will try delete this field it will be prevented and show the message.

To show required message on save you must add this rule to your screen rules, eg. 'content.*.repeater' => 'required'

You also can rename button label with your own with method button_label(). eg.

RepeaterField::make('repeater')
    ->title('Repeater')
    ->layout(App\Http\Orchid\Layouts\Repeaters\RepeaterFields::class)
    ->button_label('Add new repeater field')

orchid-repeater-field's People

Contributors

bistory avatar copostic avatar imitronov avatar leshkens avatar mavsan avatar nks avatar osbre avatar psalador avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.