-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Custom collection type displays "label empty" when adding new element #1399
Comments
I think it's the normal behavior (in a new view) of EasyAdmin when you embedd a form related to an entity . It tells that the property that defines the relationship (for example Do you think that it should be preferable to avoid this label ? |
Hi @CruzyCruz On the one hand, I think keeping the "empty" before adding new element is normal (same thing if we've deleted all the children), but on the other hand, when we've added a new element, for me (and for customer), it's weird to keep it, even if u'r right, it's not created yet. I understand your explanation but why it disappears if validation fails? cause no persist yet and no relations are set ; so if it was a wanted state, why this difference between load and reload? @javiereguiluz what's your point of view? |
I tried the following to understand why the label empty is displayed when validation fails: I have a easy_admin:
Restaurant:
class : FBN\GuideBundle\Entity\Restaurant
form:
fields:
- { property: 'coordinates', type: 'FBN\GuideBundle\Form\CoordinatesType', type_options: { required: true } } I introduced those two tests in my code:
class Restaurant extends Article
{
/**
* @ORM\OneToOne(targetEntity="FBN\GuideBundle\Entity\Coordinates", inversedBy="restaurant", cascade={"persist","remove"})
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
* @Assert\Valid()
*/
private $coordinates;
/**
* Set coordinates.
*
* @param \FBN\GuideBundle\Entity\Coordinates $coordinates
*
* @return Restaurant
*/
public function setCoordinates(\FBN\GuideBundle\Entity\Coordinates $coordinates)
{
//////////////////////////
dump('TEST 1');
dump($coordinates);
die();
//////////////////////////
$this->coordinates = $coordinates;
$coordinates->setRestaurant($this);
return $this;
}
}
class AdminController extends BaseAdminController
{
public function createRestaurantEntityFormBuilder($entity, $view)
{
$formBuilder = parent::createEntityFormBuilder($entity, $view);
//////////////////////////
$formBuilder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
$data = $event->getData();
dump('TEST 2');
dump($data->getCoordinates());
die();
}, 900);
//////////////////////////
// .....
}
} Results:
So I suppose that when the view is displayed with error messages, |
Great catch, so now we know why no empty label are present when reloading with errors, even if the entity is not yet persisted, the relation exists. Maybe @javiereguiluz can say to us if it's possible to remove the empty label directly in front-end while adding children or a custom entity? |
Have a look at this template and this CSS file ( In this part of the doc, even if it is about list, show and search view, it is said that:
I don't know if this template is used (it seems) in edit view but it is the same HTML element Then have a look at the documentation related to advanced design configuration for edit and new view. |
yep, I already saw that, I'll give it a try when I can but I'm pretty sure that it's the same css class when collection is empty... and in this case, it's a good point to have this info. Cheers |
I fixed it with a simple css override: easy_admin:
design:
assets:
css:
- '/assets/portal/css/easyadmin-tuning.css' .field-user .collection-empty,
#shop_subdomains .collection-empty{
display:none;
} I know it's crappy but it's quick. |
I'm closing this issue because we're starting a new phase in the history of this bundle (see #2059). We've moved it into a new GitHub organization and we need to start from scratch: no past issues, no pending pull requests, etc. I understand if you are angry or disappointed by this, but we really need to "reset" everything in order to reignite the development of this bundle. |
Hi,
I've implemented a custom
collection
type with my own form type binded on my SubdomainEntity
:In my
SubdomainType
, I just have two fields:My relations between entities are like that:
Shop
have aOneToMany
toSubdomain
which have aManyToOne
toDomain
All works like a charm, entities are created, foreign keys are pretty good but the widget display the block "label empty" foreach
Subdomain
item:I also have the same problem with a simple
ManyToOne
to userEntity
:- { property: 'admin', type: 'PortalBundle\Form\Type\UserType', label: 'Email du webmaster' }
On my
UserType
, only a simpleTextType
:But it displays the same weird "empty label":
All is working but any idea of what I'm doing wrong for the widget displaying?
Thanks
EDIT
If it can helps, I haven't these empty labels when reloading with validation fail:
The text was updated successfully, but these errors were encountered: