-
Notifications
You must be signed in to change notification settings - Fork 163
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
Detail view and compatibility with Flexible Content #102
Comments
@dividy I need a working setup on how you use both packages. The dependency container still has some minor problems when used within a flexible content layout. The overall problem of the dependency container not behaving correctly on index/detail/etc is already known and I'm currently working out some solutions. |
Hello @wize-wiz ! I use this Flexible Content preset : <?php
namespace App\Nova\Flexible\Presets;
use Whitecube\NovaFlexibleContent\Flexible;
use Whitecube\NovaFlexibleContent\Layouts\Preset;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Select;
use Titasgailius\SearchRelations\SearchesRelations;
use Laravel\Nova\Fields\Status;
use Laravel\Nova\Fields\Badge;
use Sloveniangooner\SearchableSelect\SearchableSelect;
use Epartment\NovaDependencyContainer\HasDependencies;
use Epartment\NovaDependencyContainer\NovaDependencyContainer;
use Illuminate\Support\Facades\Route;
class ProductPreset extends Preset
{
use HasDependencies;
/**
* Create a new preset instance
*
* @return void
*/
public function __construct()
{
}
/**
* Execute the preset configuration
*
* @return void
*/
public function handle(Flexible $field)
{
$field->button('Ajouter un produit');
$field->confirmRemove($label = 'Confirmez la suppression du produit : ', $yes = 'Supprimer', $no = 'Annuler');
$field->hideFromIndex();
$fields = [
Select::make('Type de contrat', 'type')->options([
'L' => 'Location',
'R' => 'Relevé',
'V' => 'Vente',
'VU' => 'Vente unique',
'VL' => 'Vente & Location',
])->displayUsingLabels()->rules('required'),
NovaDependencyContainer::make([ Text::make('Prix en Location (htva)', 'price_rent') ])->dependsOn('type', 'L'),
NovaDependencyContainer::make([ Text::make('Prix en Location (htva)', 'price_rent') ])->dependsOn('type', 'VL'),
NovaDependencyContainer::make([ Text::make('Prix de Vente (htva)', 'price_sale') ])->dependsOn('type', 'V'),
NovaDependencyContainer::make([ Text::make('Prix de Vente (htva)', 'price_sale') ])->dependsOn('type', 'VU'),
NovaDependencyContainer::make([ Text::make('Prix de Vente (htva)', 'price_sale') ])->dependsOn('type', 'VL'),
NovaDependencyContainer::make([ Text::make('Prix du Relevé (htva)', 'price_reading') ])->dependsOn('type', 'R'),
];
$field->addLayout('Produit', 'product', $fields);
}
} |
@dividy This is a general problem. What you are basically doing is declaring multiple fields with the same name. All fields have to be present though. But from what I can read from your code, maybe this is what you try to accomplish? public function handle(Flexible $field)
{
$field->button('Ajouter un produit');
$field->confirmRemove($label = 'Confirmez la suppression du produit : ', $yes = 'Supprimer', $no = 'Annuler');
$field->hideFromIndex();
$fields = [
Select::make('Type de contrat', 'type')->options([
'L' => 'Location',
'R' => 'Relevé',
'V' => 'Vente',
'VU' => 'Vente unique',
'VL' => 'Vente & Location',
])->displayUsingLabels()->rules('required'),
NovaDependencyContainer::make([ Text::make('Prix en Location (htva)', 'price_rent') ])
->dependsOn('type', 'VL')
->dependsOn('type', 'L'),
NovaDependencyContainer::make([ Text::make('Prix de Vente (htva)', 'price_sale') ])
->dependsOn('type', 'V')
->dependsOn('type', 'VU')
->dependsOn('type', 'VL'),
NovaDependencyContainer::make([ Text::make('Prix du Relevé (htva)', 'price_reading') ])
->dependsOn('type', 'R'),
];
$field->addLayout('Produit', 'product', $fields);
} Chaining |
Yes that's intended. I noticed the dependent input fields id are called "price_rent", "price_sale" and "price_reading" instead of eg. "02d76404b3373b65__price_rent" is it intended ? Do you have any idea why saving is OK but editing shows the value of the last item ? |
Any idea @wize-wiz ? :) |
@dividy I have to rebuild the setup your using and try to understand the problem. This won't happen until the first week of the new year. Happy holiday :) |
Would be great because I can't deliver my app to the customer next week without this. |
Hi @wize-wiz, happy new year ! Any chance for an update in the next days ? |
Same here. I have a similar problem, with an easier setup: public function fields(Request $request)
{
return [
ID::make()->sortable(),
Flexible::make("Data")
->addLayout("Simple Layout", "html", [
Select::make("Type", "type")->options([
"html" => "HTML",
"plain" => "Plaintext"
]),
NovaDependencyContainer::make([
Trix::make('Content', 'html_content')
])->dependsOn('type', "html"),
NovaDependencyContainer::make([
Textarea::make('Content', 'plain_content')
])->dependsOn('type', "plain")
])
];
} If you now have for example the following input data:
You get DB entry like this: [{
"layout": "html",
"key": "2244b3b27a11678a",
"attributes": {
"type": "html",
"html_content": "<div>html 1<\/div>"
}
}, {
"layout": "html",
"key": "8852edff81ca0ed3",
"attributes": {
"type": "plain",
"plain_content": "Plain 1"
}
}, {
"layout": "html",
"key": "668ca9a911074e49",
"attributes": {
"type": "plain",
"plain_content": "Plain 2"
}
}] But I get a result like this, on the edit form
and on detail view as well: |
Any update on this? |
Any update? |
@iBet7o I'm getting the same property of non-object error with a layout using flexible-content. In the This is my layout using Nova 2.12.0, felxible-content 0.2.3 and 1.2.11 of this package.
|
@Paradiddley try to use the development branch, only branch so far that supports flexible content and inline relationship. |
@wize-wiz I've updated the package to use that branch but I get another error
|
@Paradiddley sure PR would be great 👍 |
@wize-wiz any update? |
Hello @dividy, @bernhardh, @wize-wiz. After 5 days of hard fight against the bug, we have managed to solve it. The problem comes because NovaDependencyContainer within flexible overwrites the values of its fields with the value of the last one.
I hope it helps you. Greetings |
Running into the same issue, the fixes (including the open PR) seem to fix the issue. Any ETA on a release? |
I'm getting the same issue I believe, though the error message nova throws is now |
Resolved with @albertgpdevtrioteca 's suggestion combined with @Paradiddley 's
|
How and where did you do that? |
@stonkeep copy pasted that code into my layout... works :D Thanks @albertgpdevtrioteca !!! |
Hello,
I'm using Nova Dependency Container inside Flexible Content.
Any of you using these 2 together successfully ?
I'm having 2 issues :
Problem 1 - If I add 2 products to my "product" layout, values are saved correctly in DB but on the edit form, the products's fields have the last product's values (eg. in DB: sale_price: 1 / sale_price: 3 gives sale_price: 3 / sale_price: 3 in the edit form).
Problem 2 - It won't show dependent fields on the detail view when values are matched...
Any idea ?
The text was updated successfully, but these errors were encountered: