Skip to content
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

[WIP] New behaviour property to populate the virtual name #171

Open
wants to merge 5 commits into
base: master/elche
Choose a base branch
from

Conversation

shaoshiva
Copy link
Collaborator

Adds a new behaviour property that gives the ability to populate the virtual name with something other than the title. The value of this new behaviour property can be either a property or a method of the model.

Be careful, this new property will not affect the javascript part of the renderer that will always use the title to dynamically generates the virtual name.

To make it work with the renderer we need to rethink the way the virtual name is dynamically generated in javascript (eg. with an ajax call).

Adds a new behaviour property that give the ability to populate the virtual name with something other than the title. The value of this new behaviour property can be either a property or a method of the model.
if (!empty($this->_properties['populate_property'])) {
if (isset($item->{$this->_properties['populate_property']})) {
return $item->{$this->_properties['populate_property']};
} elseif (method_exists($item, $this->_properties['populate_property'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have done the other way around : give priority to method and then to property.

@Meroje
Copy link
Collaborator

Meroje commented Mar 31, 2015

It needs to accept a closure to allow dynamic insertion of the behaviour imo.

@vrcAlbert
Copy link
Contributor

It needs to accept a closure to allow dynamic insertion of the behaviour imo.

Indeed, using closure must be possible if methods added by behaviours are not recognized by "method_exists".
That would be the only two ways to override it.

@Foine
Copy link
Collaborator

Foine commented Apr 1, 2015

@Meroje & @vrcAlbert 👍

1 similar comment
@jguyomard
Copy link
Collaborator

@Meroje & @vrcAlbert 👍

@shaoshiva shaoshiva changed the title New behaviour property to populate the virtual name [WIP] New behaviour property to populate the virtual name Oct 26, 2016
@shaoshiva
Copy link
Collaborator Author

PR updated :

  • implements the populate callback in the renderer's javascript (via an AJAX request)
  • adds an option to regenerate the virtual name after creation (eg. to generate a virtual name with the item ID)

Todo: implement a mechanism in the renderer's javascript to observe fields and regenerate the virtual name when they change (currently only the title is observed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants