Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced possibilities in array / repeater fields #87

Merged
merged 2 commits into from
Sep 1, 2021

Conversation

StfnSl
Copy link
Contributor

@StfnSl StfnSl commented Aug 30, 2021

Two traits expanded to intervene in the array and repeaters fields via the updated function before validation

parseFunctionNameFrom rewritten, getKeyIndexFrom inserted
Added the index of the field, or NULL in the eventual function call
@@ -71,7 +71,8 @@ protected function validationAttributes(): array
public function updated($field, $value): void
{
$function = $this->parseFunctionNameFrom($field);
if (method_exists($this, $function)) $this->$function($value);
$fieldIndexKey = $this->getKeyIndexFrom($field)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ; semicolon

@tanthammar
Copy link
Owner

Hi @ra-V-en
Thank you for your contribution! :)

Can you please give me a code example on what this PR solves.

@tanthammar tanthammar merged commit 7b2b34c into tanthammar:master Sep 1, 2021
tanthammar added a commit that referenced this pull request Sep 1, 2021
@StfnSl
Copy link
Contributor Author

StfnSl commented Sep 1, 2021

Hi @ra-V-en
Thank you for your contribution! :)

Can you please give me a code example on what this PR solves.

Yes here is an example:


   public function updatedFieldsInput($value, $indexKey){
        //do something with the value
    }


    public function fields()
    {
        return [
            Repeater::make('Fields')->fields([
                Input::make('input')->required()->rules()->required(),
                Select::make('select')->options([1, 2, 3]),
                Checkbox::make('checkbox')->rules('boolean')->default(true)
            ]),
        ];
    }

@tanthammar
Copy link
Owner

Ah, now I see. That's great. I'll pull it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants