Comments (8)
Apologies for the horrific markdown!
from tall-forms.
I am not är the office right now. A small note from my phone:
Try $selected_channels = data_get($this->relationship_data, 'channel_ids');
dd($selected_channels);
Works?
Don't remember, on the fly, if it's relationhip_data or relationships_data.
Please try both and let me know :)
(Very hard to reply w the phone keyboard)
from tall-forms.
Back at the office again.
The relation() save method worked differently in v3... disregard my previous comment about $relationship_data.
I released a fix 4.1.3.
Upgrade and this should work as documented:
public function saveChannelIds($validated_value)
{
//get the options that the user selected via the field name
$selected_channels = $validated_value;
dd($selected_channels);
}
Please let me know if there are any other errors, or please close this issue :).
Thank you for reporting.
//Tina
from tall-forms.
Thanks for the fix, however the $this->model
is returning as bool true, and not an instance. Is this related, or could it be something else that ive done (my code is still as above - didnt want to touch anything else just in case.)
from tall-forms.
public function saveChannelIds($validated_value)
{
$selected_channels = $validated_value;
dd($this->model);
if (blank($selected_channels)) {
$this->model->channels()->detach(); //detach all existing relations
} else {
$allowed_to_sync = filled($selected_channels) ? array_intersect($selected_channels, array_values($this->channels)) : [];
if (filled($allowed_to_sync)) $this->model->channels()->sync($selected_channels);
}
}
from tall-forms.
Have just been tinkering and it appears that the $this->model
changes state somewhere in the TallForm.php success()
function.
Did a dump of $this->model
before and after this line:
filled($this->model) && $this->model->exists ? $this->onUpdateModel($model_fields_data) : $this->onCreateModel($model_fields_data);
Before: return instance of the model as expected
After: returns true
Will keep looking as to what is making that change, but hopefully thats helpful.
from tall-forms.
Please ignore the above 'error'. It was due to lazy copy & paste!
In your example here you have a method that overrides the default onUpdateModel
function.
// Optional method, this already exists in the TallForm trait
public function onUpdateModel($validated_data)
{
$this->model = $this->model->update($validated_data);
}
It CLEARLY states it is optional HAHA
It behaves differently to the onUpdateModel
function in the TallForm.php file
public function success($model_fields_data)
{
// you have to add the methods to your component
filled($this->model) && $this->model->exists ? $this->onUpdateModel($model_fields_data) : $this->onCreateModel($model_fields_data);
}
The true
response was coming from the one in my model returning a true to the model being saved, and then setting that as the new value for $this->model
.
I will close this now as you've solved the initial thing for me, the second part was clearly just a user error!
Thanks!
from tall-forms.
@goldienz
Good catch,
I updated the stubs files and documentation to avoid confusion.
v4.1.4, has the correct syntax in the stub files.
Thank you for telling me.
from tall-forms.
Related Issues (20)
- Translations not working HOT 4
- placeholder is not defined on Checkboxes HOT 2
- livewireValue is not defined HOT 7
- how to store data in a json column? HOT 1
- Notifications from session are empty HOT 4
- Dots in Validation error message are stripped HOT 6
- "views/components/pages/default.blade.php" not created HOT 2
- form-select HOT 3
- Undefined variable $form HOT 2
- setting disabled() doesn't apply default form styles
- fieldWith does not have any effect HOT 2
- Missing clear example in Documentation HOT 1
- When view:cache, Unable to locate a class or view for component [pages.default] HOT 6
- ABORTING: This installer only supports Laravel >= v8 HOT 2
- Version for new Livewire HOT 4
- With Radio field can´t get value in form_data HOT 6
- Require php ^7.4.4 -> your php version (8.2.12) does not satisfy that requirement. HOT 1
- FileUpload with Repeater HOT 2
- Sponsor access? HOT 2
- Module not found: Error: Can't resolve '@alpinejs/trap' HOT 2
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 tall-forms.