青木
青木
Explore posts from servers
FFilament
Created by 青木 on 7/3/2024 in #❓┊help
Images uploaded without the FileUpload component cannot be displayed.
No description
16 replies
FFilament
Created by 青木 on 7/2/2024 in #❓┊help
How to dynamically control the configuration of other components in a form?
I need to change another option for selecting components I tried to write it but it doesn't work. Is there any way to achieve this behavior? Also attribute_ids changes I may change another component multilevel dependencies will be updated? For example, a <- b <- c, when c is modified, b needs to be modified at the same time, and a can only be modified when b is done.
Forms\Components\Select::make('attribute_parent_ids')
->label('属性父级')
->options(ProductAttribute::whereNull('parent_id')
->pluck('title', 'id'))
->multiple()
->live(true)
->afterStateUpdated(function (
Forms\Components\Select $component
) {

/** @var Forms\Components\Select $select */
$select = $component->getContainer()
->getComponent('valueIds');

$options = ProductAttribute::whereNotNull('parent_id')
->whereIn('parent_id',
$component->getState())
->pluck('title',
'id');

// remove is cancel options
$newState =
collect($select->getState())
->filter(function ($value) use (
$options
) {
return isset($options[$value]);
})
->toArray();

$select->state($newState)
->options($options);
})
->nullable(),
Forms\Components\Select::make('attribute_ids')
->label('属性')
->options([])
->multiple()
->live(true)
->nullable()
->key('valueIds')
Forms\Components\Select::make('attribute_parent_ids')
->label('属性父级')
->options(ProductAttribute::whereNull('parent_id')
->pluck('title', 'id'))
->multiple()
->live(true)
->afterStateUpdated(function (
Forms\Components\Select $component
) {

/** @var Forms\Components\Select $select */
$select = $component->getContainer()
->getComponent('valueIds');

$options = ProductAttribute::whereNotNull('parent_id')
->whereIn('parent_id',
$component->getState())
->pluck('title',
'id');

// remove is cancel options
$newState =
collect($select->getState())
->filter(function ($value) use (
$options
) {
return isset($options[$value]);
})
->toArray();

$select->state($newState)
->options($options);
})
->nullable(),
Forms\Components\Select::make('attribute_ids')
->label('属性')
->options([])
->multiple()
->live(true)
->nullable()
->key('valueIds')
2 replies
FFilament
Created by 青木 on 8/19/2023 in #❓┊help
How do I submit a form automatically?
I'm implementing a function to bind tenants. 1. I want to execute the bind function directly when the url contains /bind?code=abc 2. render a page for the user to enter the code when it doesn't exist. What should I do? I tried to do this, but I don't know how the form should be submitted automatically.
TextInput::make('code')
->label('Code')
->required()
->helperText(
'Please enter the code provided by your company. If you do not have a code, contact your company administrator.'
)
->default(function (Set $set, Request $request) {
if ($request->has('code')) {
return $request->get('code');
}
return null;
}),
TextInput::make('code')
->label('Code')
->required()
->helperText(
'Please enter the code provided by your company. If you do not have a code, contact your company administrator.'
)
->default(function (Set $set, Request $request) {
if ($request->has('code')) {
return $request->get('code');
}
return null;
}),
2 replies
FFilament
Created by 青木 on 8/16/2023 in #❓┊help
How do I add a route that skips the tenant prefix?
2 replies