Comments (10)
uhm.. can you do a quickly test,
Instead of using creationRules
and updateRules
use just rules
if it works I think I know what may be wrong and I can issue a quickly fix...
from conditional-container.
Hi @nemrutco I just doubled checked.. it does work with creationRules
and updateRules
did you import use HasConditionalContainer;
?
from conditional-container.
i just tried
ConditionalContainer::make([
Text::make(__('Username'), 'username')->rules('required'),
])->if('role != 3'),
and it still doesn't work.
Yes i imported use HasConditionalContainer
from conditional-container.
Is this how you are using it?
public function fields(Request $request)
{
return [
Select::make(__('Role'), 'role')
->options([
1 => 'A',
2 => 'B',
3 => 'C',
]),
ConditionalContainer::make([
Text::make(__('Name'), 'name')
->creationRules('required', 'max:255')
->updateRules('required', 'max:255'),
])->if('role != 3'),
];
}
role
needs to be an actual field in your model otherwise it wont be able to detect it
If its not.. you can try something like this: #7 (comment)
from conditional-container.
public function fields(Request $request)
{
return [
ID::make()->sortable()
->onlyOnForms(),
BelongsTo::make(__('Role'), 'role')->withMeta([
'belongsToId' => $this->role->id ?? null
]),
Text::make(__('Name'), 'name')->onlyOnIndex(),
ConditionalContainer::make([
Text::make(__('Username'), 'username')
->sortable()
->creationRules('required', 'unique:users,username', 'max:254', 'alpha_dash')
->updateRules('sometimes', 'required', 'unique:users,username,{{resourceId}}', 'max:254', 'alpha_dash'),
Password::make(__('Password'), 'password')
->onlyOnForms()
->creationRules('required', 'string', 'min:8')
->updateRules('sometimes', 'required', 'string', 'min:8'),
])->if('role != 3'),
Text::make(__('Employee Number'), 'employee_number')
->sortable()
->rules('required', 'integer'),
BelongsToMany::make(__('Stores'), 'stores')
->searchable(),
MorphOne::make(__('Card'), 'card'),
BelongsTo::make(__('Profile'), 'profile', Profile::class)
->inline()
->rules('required')
->hideFromIndex(),
HasMany::make(__('Sales'), 'sales'),
];
}
from conditional-container.
role
is an actual field. And i just tried another field as well.
ConditionalContainer::make([
Text::make(__('Employee Number'), 'employee_number')
->sortable()
->rules('required', 'integer'),
])->if('role != 3'),
still not working.
Did you mean role
has to be a field in model table? Because role is relationship in my case.
from conditional-container.
@nemrutco fixed on version v1.1.3, the problem was with the BelongsTo
and the !=
operator, on the way I found it had the same issue with other operators as well >= <= != !==
it's now fixed, try again
from conditional-container.
Fixed! Thank you.
from conditional-container.
Another issue related to this:
when password field is nullable, it submits password to db as null and db updates the value to null (db password field is nullable) but when i use without ConditionalContainer, null value does not update db so old password stays. Why does it update db when it is nullable? it should ignore the field.
Password::make(__('Password'), 'password')
->onlyOnForms()
->creationRules('required', 'string', 'min:8')
->updateRules('sometimes', 'nullable', 'string', 'min:8')
from conditional-container.
Please open another issue with this otherwise it may get forgotten in here
from conditional-container.
Related Issues (20)
- Conditional Container not showing in detail view page HOT 8
- Column not found error when using media package HOT 9
- TypeError: this.field.expressionsMap is undefined HOT 1
- Upgrading to Nova 3.21 breaks ConditionalContainer with HasMany field HOT 5
- BelongsToManyField still not working inside ConditionalContainer HOT 3
- Use of a resource field inside Flexible layout HOT 1
- Fields Are Not Updating HOT 3
- Default and Readonly
- BooleanGroup support HOT 1
- field not shown in index view HOT 4
- v1.4.1 not working HOT 2
- if condition not working with boolean values HOT 1
- Can't download thumbnail if conditionalcontainer is used HOT 1
- Field authorization not working HOT 1
- MorphTo bug
- Add Laravel Nova 4 support HOT 9
- Nova 4 Support HOT 2
- Bug with Boolean Field inside Conditional Container
- Validations not working HOT 2
- how about nova4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conditional-container.