Good understanding of the name attribute of the input fields

hello all of you 

I would like to know if the attributes on the new object (ElggObject, ElggGroup) created on elgg can only have as attribute name on an input field or other than (title and description), because I have created an ElggGroup object which here is the form

​// title
echo elgg_view_field([
    '#type' => 'text',
    '#label' => elgg_echo('camerproject:title'),
    'name' => 'title',
    'value' => elgg_extract('title', $vars),
    'required' => true,
]);

echo elgg_view_field([
  '#type' => 'file',
  '#label' => elgg_echo('camerproject:logoproject'),
  '#help' => elgg_echo('camerproject:edit:icon:limit', [$upload_limit]),
  'name' => 'icon',
  'value' => elgg_extract('icon', $vars),
  'required' => true,
]);

 echo elgg_view_field([
     '#type' => 'plaintext',
     '#label' => elgg_echo('camerproject:summery'),
     'name' => 'summery',
     'value' => elgg_extract('summery', $vars),
     'required' => true,
 ]);

 echo elgg_view_field([
     '#type' => 'dropdown',
     '#label' => elgg_echo('camerproject:progress'),
     'name' => 'progress',
     'options_values' => $progress,
     'value' => elgg_extract('progress', $vars),
     'required' => true,
  ]);

 

and when I try to interpret my different attributes. of which here a function defined for this is:

/**
 * {@inheritDoc}
 * @see ElggEntity::getURL()
 */
public function getURL() {
        $friendly_title = elgg_get_friendly_title($this->getDisplayName());

        return elgg_normalize_url("camerproject/profile/{$this->guid}/{$friendly_title}");
} 

but the function getDisplayName () does not work the other attributes except on those whose name of the input field is (title and description)

 

Please help me,

regards,

  • You can't use all functions for all kind of entity objects. For example, on ElggUser objects will have a display name and therefore trying to make use of getDisplayName with a group or object entity won't work.

    See http://learn.elgg.org/en/stable/design/database.html for an overview of the data model of Elgg and the properties available by default for the different types of entities. For a refence on available functions you can check out http://reference.elgg.org/index.html (see also the classes section there). Or study the code of Elgg to see what is done in Elgg core and the bundled plugins. For example for groups you could study the input form views and actions to see what input fields are used and processed. I would suggest to not change any default fields but rather add your owns if necessary.

  • thanks,

    I will try again and if I have any problems I will come back

  • @iionly

    in addition to that I would like to know, can I send you the zip of my plugin so that you also help me to check.

    if it's possible of course ?????

  • @iionly

    You can't use all functions for all kind of entity objects. For example, on ElggUser objects will have a display name and therefore trying to make use of getDisplayName with a group or object entity won't work.

    This is not correct `->getDisplayName()` was added because of the fact that the title/name is stored in different columns. ->getDisplayName() will return the name of an ElggUser and ElggGroup and the title of an ElggObject (eg blog)

    @foka_patrick

    You have to make sure you store all the information in the database, this isn't done magically. Look at http://learn.elgg.org/en/stable/guides/actions.html

  • @Jerome

    By passing my data does not arrive in comic, when I click on the save button. it tells me that the object is well save and I go to the elgg_object_entity table. I have tuples with the values ​​of title and description empty. and I do not know why. I wanted to create my own table in the database given my disadvantage by advising me to use the datamodel elgg. and it is that I do since then and I have problems

    •  
    •  can I send you the zip of my plugin so that you also help me to check.

      if it's possible of course ?????

    regards, 
  • I come back after having the information on the link I had. Here I am told that we should not confuse ElggGroup and the plugin groups in addition that we can have several groups. this is where it becomes interesting. because the plugin groups to a table in database.

    and now about my camerproject plugin or I add other fields on the form. The question that I ask myself is that of knowing must I continue with the meta model of elgg (if not because it has only 2 attributes name & description): if yes how should I treat the new fields.

    must i create a new table in the database (it make the heart of elgg), otherwise tell how i have to do.

    These are the questions I have been asking myself for some time and I need your help.

    regards,

    @foka_patrick

  •  

    i also add if you have any examples please let me see

  • The question that I ask myself is that of knowing must I continue with the meta model of elgg (if not because it has only 2 attributes name & description):

    Yes

    must i create a new table in the database (it make the heart of elgg), otherwise tell how i have to do.

    NO, http://learn.elgg.org/en/stable/guides/dont-modify-core.html

    i also add if you have any examples please let me see

    http://learn.elgg.org/en/stable/tutorials/blog.html

  • But the problem there is that it's ElggObject  then i use ElggGroup on plugin. 

  • for more i already done this example.