-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Added ability to auto-add fields to new fieldsets #12916
Conversation
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
…value Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
PR Summary
|
Signed-off-by: snipe <snipe@snipe.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This...I like this.... 👍🏾
if ($fields->count() > 0) { | ||
foreach ($fields as $field) { | ||
$field_ids[] = $field->id; | ||
} | ||
|
||
$fieldset->fields()->sync($field_ids); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side-note: since $fields
is a collection you could skip the foreach
and do
if ($fields->count() > 0) { | |
foreach ($fields as $field) { | |
$field_ids[] = $field->id; | |
} | |
$fieldset->fields()->sync($field_ids); | |
} | |
if ($fields->count() > 0) { | |
$fieldset->fields()->sync($fields->pluck('id')); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure what will work as expected - it feels to me more like it would only associate that one it's syncing to, unsyncing the others (which is why I set it up as an array).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be ok. $fields->pluck('id')
will return a collection of the ids, which can be cast to an array, in the same way $field_ids[]
is formatted.
Definitely don't hold up the PR for this comment though 😄
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
This introduces two new (related) features:
Ability to add fields to field sets on fieldset create/edit
Screen.Recording.2023-04-25.at.9.35.39.PM.mov
Ability to auto-add fields to any new fieldsets that get created afterwards
Screen.Recording.2023-04-25.at.9.36.40.PM.mov