Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Controller
- $languages = $this->Query->getAllDataList('Languages',
- [
- 'Languages.is_published' => 1,
- 'Languages.is_active' => 1
- ],
- ['Languages.name']
- );
- //Template
- <div class="form-group">
- <label for="mother_tounge_language_id">Mother Tounge</label> <!-- Mother Tounge -->
- <?= $this->Form->select('mother_tounge_language_id',
- $languages,
- [
- 'id' => 'mother_tounge_language_id',
- 'empty' => '(Choose mother tounge)',
- 'class' => 'form-control select2',
- 'required' => 'required'
- ]
- )?>
- </div>
- //QueryComponent
- /**
- * Get List for Tables
- *
- * @param $model string null
- * @param $conditions array Pass conditions (Where clause)
- * @param $order array Order By
- *
- * @return array
- */
- public function getAllDataList($model = null, $conditions = [], $order = [], $contain = []) {
- if ($model != null) {
- $items = TableRegistry::get($model);
- }
- $query = $items->find('list')
- ->where($conditions)
- ->contain($contain)
- ->order($order);
- return $query;
- }
Add Comment
Please, Sign In to add comment