Oliverdam
Oliverdam
FFilament
Created by Oliverdam on 9/9/2024 in #❓┊help
Multiple add actions on repeater
No description
7 replies
FFilament
Created by Oliverdam on 9/9/2024 in #❓┊help
Multiple add actions on repeater
If possible i wanted to have the action on the repeater. This did give the idea of having it on a section, so I'll give that a try if it's not possible to add the action to the repeater. Thank you very much.
7 replies
FFilament
Created by Oliverdam on 5/21/2024 in #❓┊help
Relationship manager doesn't show up on edit page
Thanks, that's what was blocking it. I don't know why it's blocking it though, since I have a role that's bypassing all the policies and that works for everything except this one instance. But thanks for pointing me in the right direction.
8 replies
FFilament
Created by Oliverdam on 5/21/2024 in #❓┊help
Relationship manager doesn't show up on edit page
Yes
8 replies
FFilament
Created by Oliverdam on 9/12/2023 in #❓┊help
Triggering state change
Thanks I'll try and dive into it.
18 replies
FFilament
Created by Oliverdam on 9/12/2023 in #❓┊help
Triggering state change
Did you mean to watch the state? If I do that I can confirm that it only updates the state when I manually type in the textbox. Not when Laraberg changes it.
18 replies
FFilament
Created by Oliverdam on 9/12/2023 in #❓┊help
Triggering state change
Not as far as I know. And the source for the js doesn't seem to be public, only the minified version.
18 replies
FFilament
Created by Oliverdam on 9/12/2023 in #❓┊help
Triggering state change
no the data for the textarea is always null. Until I manually type in it.
18 replies
FFilament
Created by Oliverdam on 9/12/2023 in #❓┊help
Triggering state change
In handleRecordCreation
18 replies
FFilament
Created by Oliverdam on 9/12/2023 in #❓┊help
Triggering state change
It does, when I submit it flashes there, and if I instead of creating a record dd. So it doesn't go further I can also see it. If I try submitting again after that it's still null, but if I type a letter into the textarea (that still has the content), it then gets saved when I click submit again. This is the reason i'm thinking something is not triggering the state change.
18 replies
FFilament
Created by Oliverdam on 9/11/2023 in #❓┊help
Initialize custom form component
Thanks again, that's exactly what I was looking for.
6 replies
FFilament
Created by Oliverdam on 9/11/2023 in #❓┊help
Initialize custom form component
Thanks. I'll give it a shot
6 replies
FFilament
Created by lamberttraccard on 8/13/2023 in #❓┊help
Is repeater::createItem still a thing in V3 ?
In case you didn't find a solution I had the same problem and got help in another thread. If you are able to have the code on the repeater itself you can do something like this:
Repeater::make('thing')
->addAction(fn (Action $action) => $action->after(function () {
// Do what you want when an item is added.
}));
Repeater::make('thing')
->addAction(fn (Action $action) => $action->after(function () {
// Do what you want when an item is added.
}));
This is the thread in case it helps https://discord.com/channels/883083792112300104/1148582353241911446
5 replies
FFilament
Created by Oliverdam on 9/5/2023 in #❓┊help
Modify the state of a repeater when an item is added
@.modestasv I'm really sorry, I missed your answer before. I only saw it when I went through the whole thread once again 🤦‍♂️ Your answer actually works. This is what I made work.
->addAction(fn ($action) => $action->after(function (Repeater $component) {
$component->state(function ($state) {
$answers = collect($state);
$newAnswerKey = $answers->keys()->last();
$previousAnswer = $answers->at(-2);

$answers[$newAnswerKey] = [
'order' => $previousAnswer['order'] + 1,
];

return $answers->toArray();
});
}))
->addAction(fn ($action) => $action->after(function (Repeater $component) {
$component->state(function ($state) {
$answers = collect($state);
$newAnswerKey = $answers->keys()->last();
$previousAnswer = $answers->at(-2);

$answers[$newAnswerKey] = [
'order' => $previousAnswer['order'] + 1,
];

return $answers->toArray();
});
}))
I added after() that @pboivin suggested to the Repeater, which is stupid of me cus that's a validation rule. Thank you both very much the help.
13 replies
FFilament
Created by Oliverdam on 9/5/2023 in #❓┊help
Modify the state of a repeater when an item is added
Doesn't seem to work either.
13 replies
FFilament
Created by Oliverdam on 9/5/2023 in #❓┊help
Modify the state of a repeater when an item is added
I had something like this in v2
Repeater::make('questions')
->schema([
TextInput::make('order'),
])
->registerListeners([
['repeater::createItem' => [
function (Component $component, string $statePath) {
if ($statePath !== $component->getStatePath()) {
return;
}
$component->state(function ($get) {
$questions = collect($get('questions'));
$newQuestionKey = $questions->keys()->last();
$previousQuestion = $questions->at(-2);

$questions[$newQuestionKey] = [
'order' => $previousQuestion['order'] + 1,
];
return $questions;
});
},
],]
]);
Repeater::make('questions')
->schema([
TextInput::make('order'),
])
->registerListeners([
['repeater::createItem' => [
function (Component $component, string $statePath) {
if ($statePath !== $component->getStatePath()) {
return;
}
$component->state(function ($get) {
$questions = collect($get('questions'));
$newQuestionKey = $questions->keys()->last();
$previousQuestion = $questions->at(-2);

$questions[$newQuestionKey] = [
'order' => $previousQuestion['order'] + 1,
];
return $questions;
});
},
],]
]);
And in v3 I tried adding
->addAction(fn ($action) => $action->dispatch('addItem'))
->addAction(fn ($action) => $action->dispatch('addItem'))
To the repeater and changing the event listener to listen for this instead. Which might be incorrect use of it, I couldn't completely wrap my mind around how it worked.
13 replies
FFilament
Created by Oliverdam on 9/5/2023 in #❓┊help
Modify the state of a repeater when an item is added
I want to set the values in the new item, based off what the values are in the previous item. I.e. if the order field in the previous item was 3 the new item should have the order field prefilled with 4.
13 replies