Ejemplo n.º 1
0
                ?>
, 
            <?php 
            }
            ?>
          
          <?php 
        } elseif (Arr::get($belongs_to, $name)) {
            ?>
            
            <?php 
            $column_name = NULL;
            $is_model = method_exists($row->{$name}, 'list_columns');
            $belongs_to_model = $row->{$name};
            if (!$is_model) {
                $belongs_to_model = Model_App::factory(ORM::get_model_name($row->object_name()), $row->{$name});
            }
            $name = $belongs_to_model->object_name();
            foreach ($belongs_to_model->list_columns() as $column => $values) {
                if (Arr::get($values, 'type') === 'string' and $column_name === NULL) {
                    $column_name = $column;
                }
            }
            ?>
            <a href="<?php 
            echo URL::site('manager/' . $name . '/edit/' . $belongs_to_model->id);
            ?>
"><?php 
            echo $belongs_to_model->{$column_name};
            ?>
</a>
Ejemplo n.º 2
0
		<?php 
        echo Form::select($select_name, $belongs_to_values, $model->{$select_name}, array('class' => 'form-control'));
        ?>
		
		<?php 
    } elseif (!empty($has_many) and Arr::get($has_many, $name) and Arr::path($has_many, $name . '.through')) {
        ?>

		<?php 
        $column_name = NULL;
        $model_name = ORM::get_model_name($name);
        $far_primary_key = Arr::path($has_many, $name . '.far_primary_key', 'id');
        if (!class_exists($model_name)) {
            $model_name = Arr::path($has_many, $name . '.model');
        }
        $parent_has_many = Model_App::factory($model_name);
        foreach ($parent_has_many->list_columns() as $column => $values) {
            if (Arr::get($values, 'type') === 'string' and $column_name === NULL) {
                $column_name = $column;
            }
        }
        $selects = $parent_has_many->find_all()->as_array('id', $column_name);
        $selected = $model->{$name}->find_all()->as_array(NULL, $far_primary_key);
        echo '<div style="max-height: 400px; overflow-x: auto; border: 1px solid #ddd; border-radius: 3px; padding: 0 10px;">';
        foreach ($selects as $select_id => $select_name) {
            echo '<div class="checkbox">';
            echo '<label class="checkbox-inline">';
            echo Form::checkbox($name . '[]', $select_id, in_array($select_id, $selected)) . ' ' . $select_name . ' ';
            echo '</label>';
            echo '</div>';
        }