Title: dodmax's Replies | WordPress.org

---

# dodmax

  [  ](https://wordpress.org/support/users/dodmax/)

 *   [Profile](https://wordpress.org/support/users/dodmax/)
 *   [Topics Started](https://wordpress.org/support/users/dodmax/topics/)
 *   [Replies Created](https://wordpress.org/support/users/dodmax/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/dodmax/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/dodmax/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/dodmax/engagements/)
 *   [Favorites](https://wordpress.org/support/users/dodmax/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/users/dodmax/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/dodmax/replies/page/2/?output_format=md)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[ACF Photo Gallery Field] ACF Gallery Field Not Showing up in Elementor Gallery Widget](https://wordpress.org/support/topic/acf-gallery-field-not-showing-up-in-elementor-gallery-widget/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/acf-gallery-field-not-showing-up-in-elementor-gallery-widget/#post-12199085)
 * [@thebigbanik](https://wordpress.org/support/users/thebigbanik/) There is an 
   extra step with ACF Gallery: you need to click the wrench icon and select the
   gallery name.
 * screenshot: [http://prntscr.com/q5dbke](http://prntscr.com/q5dbke)
 * Also make sure that “Return Format” is set to “Image Array” under this field’s
   settings in ACF.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] Accessing fields other than foreign_keys in Join Tables](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-fields-other-than-foreign_keys-in-join-tables/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-fields-other-than-foreign_keys-in-join-tables/#post-2970874)
 * You can try to write your own function to query this list in your model and do
   some tweaking on the find function:
 * For example in your Book model:
 *     ```
       public function get_book_list()
       {
          return $this->find(array(
             'additional_selects' => array('AuthorBook.rank'),
             'joins' => array('Author'),
          ));
       }
       ```
   
 * I’m not sure about the alias given to the table, worst case print the SQL query
   first to make sure of it.
 * You can customize your request even more if needed:
 *     ```
       $this->find(array(
          'selects' => array(...)
          'joins' => array(
                 'table' => '...',
                 'on' => 'Author.id = ...',
                 'alias' => 'Author',
                 'type' => 'LEFT JOIN'
             )
          'conditions' => array(...) //or sql string
       ));
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] belongs_to_dropdown does not populate](https://wordpress.org/support/topic/plugin-wp-mvc-belongs_to_dropdown-does-not-populate/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-belongs_to_dropdown-does-not-populate/#post-2970305)
 * AS far as I know you have to provide the list yourself to the belongs_to_dropdown()
   function.
 * The way to do it is to override the add and the edit functions in your admin 
   controller and to query it there then use set_object to make it available in 
   the view (where the belongs_to_dropdown call is).
 * Have a look at the event-calendar-example for an example:
    \plugins\events-calendar-
   example\app\controllers\admin\admin_events_controller.php
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] "Fatal Error: Field "name" not found for use in a form input"](https://wordpress.org/support/topic/plugin-wp-mvc-fatal-error-field-name-not-found-for-use-in-a-form-input/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-fatal-error-field-name-not-found-for-use-in-a-form-input/#post-2965547)
 * Does your database contain a “name” field for this table?
 * You will most likely have to change the “add” and “edit” forms in views/admin!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] code generation utility wpmvc throwing error](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-utility-wpmvc/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-code-generation-utility-wpmvc/#post-2956824)
 * Are you sure register_argc_argv is on?
    Did you try to print_r($argv) at the 
   top of core/wpmvc.php to make sure of it?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] plugin won't work without wp-mvc activated](https://wordpress.org/support/topic/plugin-wont-work-without-wp-mvc-activated/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wont-work-without-wp-mvc-activated/#post-2929724)
 * Glad it worked.
    But keep in mind that if someone installs wp-mvc (for another
   plugin) while your plugin is activated it’s gonna break the WordPress installation(
   Fatal error cannot redeclare class XXX). Removing the `require 'wp_mvc.php'` 
   should be enough to fix it. Worth throwing a note about it in your read_me 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] Does wp-mvc support shortcode and widget ?](https://wordpress.org/support/topic/does-wp-mvc-support-shortcode-and-widget/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/does-wp-mvc-support-shortcode-and-widget/#post-2832752)
 * I can confirm that Davelopware patch works well!
 * Also although it doesn’t seem to be documented, wp-mvc can automatically register
   widgets for you.
 * Just create a `my-plugin/app/widgets` folder and create a php file for each widget,
   for example `my_widget.php`.
 * Each file should contain a class following the [wordpress widget documentation](http://codex.wordpress.org/Widgets_API#Developing_Widgets)
 * Also your widget class name needs to follow the following naming convention: 
   CamelPluginName_CamelWidgetFileName
 * In the previous example your class would be named `MyPlugin_MyWidget`
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] $this->pagination() doest not work on admin controller](https://wordpress.org/support/topic/plugin-wp-mvc-this-pagination-doest-not-work-on-admin-controller/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-this-pagination-doest-not-work-on-admin-controller/#post-2910943)
 * Only public controllers have the pagination() method.
    I guess you could call`
   paginate_links($pagination);` directly.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] plugin won't work without wp-mvc activated](https://wordpress.org/support/topic/plugin-wont-work-without-wp-mvc-activated/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wont-work-without-wp-mvc-activated/#post-2929713)
 * It’s not really a problem, more of a requirement.
    Your plugin needs WP-MVC to
   be loaded in order to work.
 * I guess you could try to bundle your plugin and wp-mvc together so wp-mvc won’t
   show in the plugin tab.
 * Try moving the content of the wp-mvc folder in your plugin folder (so you will
   have my-plugin/core) and add `require 'wp_mvc.php'` on top of your my_plugin.
   php file.
 * This won’t work if you have more than one plugin using wp-mvc though.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] accessing associated models in view](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/#post-2865320)
 * Hi davelopware,
 * Glad that I could help! No extensive testing on my side yet, have to work really
   quickly for now 🙂
 * I like WP-MVC, it lacks some features but it’s an amazing piece of work and it
   works well.
    It’s true that there is some interesting hacks on Github. Hope we’ll
   be able to put together a comprehensive pull request and that the author will
   take some time to examine it!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] accessing associated models in view](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/#post-2865204)
 * Had this problem too, have a look here:
 * [http://wordpress.org/support/topic/plugin-wp-mvc-models-multiple-join-on-the-same-table?replies=2](http://wordpress.org/support/topic/plugin-wp-mvc-models-multiple-join-on-the-same-table?replies=2)
 * It doesn’t work with $includes though, I’m having an error on my side (looks 
   like a bug, didn’t took time to dive in yet).
 * Also in the future if you use has_and_belongs_to_many associations and try to
   get the value via __get() you might wanna apply this patch since there is a bug
   in v1.2
 * [https://github.com/DODMax/wp-mvc/commit/27db4e6d0b579aba8175cdf63f54700dc4dba50a](https://github.com/DODMax/wp-mvc/commit/27db4e6d0b579aba8175cdf63f54700dc4dba50a)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] accessing associated models in view](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/#post-2865186)
 * Actually it should query the value automagically for you since $object has a 
   __get() overload that does it for you.
    Just access it like this: `$object->jungle_branch-
   >name;`
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] Models: multiple join on the same table](https://wordpress.org/support/topic/plugin-wp-mvc-models-multiple-join-on-the-same-table/)
 *  Thread Starter [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-models-multiple-join-on-the-same-table/#post-2864522)
 * Ok after a lot of try and fail I figured out part of it.
    Taking the example 
   of a match between 2 teams.
 * The Match model will contain:
 *     ```
       var $belongs_to = array(
           'Hometeam' => array('foreign_key' => 'home_team_id', 'class' => 'Team'),
           'Awayteam' => array('foreign_key' => 'away_team_id', 'class' => 'Team')
       );
       ```
   
 * ‘class’ => ‘Team’ refer to the Team model name.
    The keys of the belongs_to array(‘
   Hometeam’, …) must have the first letter capitalized, rest lowercase, no underscore
   or other stuff.
 * The Match admin controller will contain:
 *     ```
       var $default_columns = array(
           'hometeam' => array('value_method' => 'admin_column_hometeam'),
           'awayteam' => array('value_method' => 'admin_column_awayteam'),
       );
   
       public function admin_column_awayteam($object)
       {
           return $object->awayteam->name; //note that awayteam is lowercased
       }
   
       public function admin_column_hometeam($object)
       {
           return $object->hometeam->name;
       }
       ```
   
 * Somehow something magic happens when calling `$object->hometeam->name` that will
   query the team name from the database and set it (you can see that $object->hometeam
   is not set before the call and is after).
 * I’m still having some trouble populating the team name on the edit form since`
   var $includes = array('Hometeam');` is causing an error…
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] Accessing other Models from a controller](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-other-models-from-a-controller/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-other-models-from-a-controller/#post-2558302)
 * Here is a little patch that would allow to reference a sub object in the format‘
   Venue.name’
 * wp-content\plugins\wp-mvc\core\helpers\mvc_helper.php line 188
 *     ```
       public function admin_table_cell($controller, $object, $column) {
          if (!empty($column['value_method'])) {
             $value = $controller->{$column['value_method']}($object);
          } else {
             $subs = explode('.', $column['key']);
             foreach ($subs as $sub)
                $object = $object->$sub;
             $value = $object;
          }
          return '<td>'.$value.'</td>';
       }
       ```
   
 * You could also patch the header cell function line 171 for the name to display
   automatically:
 *     ```
       public function admin_header_cell($label) {
          return '<th scope="col" class="manage-column">'.MvcInflector::titleize(str_replace('.', ' ', $label)).'</th>';
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP MVC] [Plugin: WP MVC] accessing associated models in view](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/)
 *  [dodmax](https://wordpress.org/support/users/dodmax/)
 * (@dodmax)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-mvc-accessing-associated-models-in-view/#post-2865122)
 * Hi,
 * Try adding `var $includes = array('JungleBranch');` in your model.
    This way 
   it should query it for you. Also try to print_r($object) somewhere to make sure
   it is / is not inside.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/users/dodmax/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/dodmax/replies/page/2/?output_format=md)