Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Sign Up

twig


Recommended Posts

Привет, народ. Переделываю модуль от 2.3 под 3. Возникла сложность с твигом, т.к. я его не знаю. В общем есть такой код:

<input type="text" name="cs_group_shipping[<?php echo $language['language_id']; ?>][shipping_name]" value="<?php echo $cs_group_shipping[ $language['language_id']]['shipping_name'];?>" placeholder="<?php echo $entry_shipping_title; ?>" class="form-control" />

это обычный php, переделываю в твиг так:

<input type="text" name="cs_group_shipping[ {{ language.language_id }} ][shipping_name]" value="{{ cs_group_shipping.language.language_id.shipping_name }}" placeholder="{{ entry_shipping_title }}" class="form-control" />

ругается на то, что в атрибуте value массив. подскажите что делать то???

Link to post
Share on other sites

тут

cs_group_shipping[ {{ language.language_id }} ]

 

cs_group_shipping[{{ language.language_id }}]

Link to post
Share on other sites
3 минуты назад, chukcha сказал:

тут


cs_group_shipping[ {{ language.language_id }} ]

 

cs_group_shipping[{{ language.language_id }}]

так cs_group_shipping - тоже переменная

Link to post
Share on other sites

тренируйтесь, тем более я не знаю структуру вашего массива

Link to post
Share on other sites
Только что, chukcha сказал:

тренируйтесь, тем более я не знаю структуру вашего массива

могу предоставить код контроллера и шаблона

Link to post
Share on other sites

это контроллер:

Спойлер



<?php
class ControllerExtensionShippingCs extends Controller {
	private $error = array();

	public function index() {
		$this->load->language('extension/shipping/cs');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('setting/setting');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_setting_setting->editSetting('cs', $this->request->post);

			$this->session->data['success'] = $this->language->get('text_success');

			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true));
		}

		$data['heading_title'] = $this->language->get('heading_title');
		
		$data['text_edit'] = $this->language->get('text_edit');
		$data['text_enabled'] = $this->language->get('text_enabled');
		$data['text_disabled'] = $this->language->get('text_disabled');
		$data['text_all_zones'] = $this->language->get('text_all_zones');
		$data['text_none'] = $this->language->get('text_none');

		$data['entry_shipping_title'] = $this->language->get('entry_shipping_title');
		$data['entry_name'] = $this->language->get('entry_name');
		$data['entry_cost'] = $this->language->get('entry_cost');
		$data['entry_allcost'] = $this->language->get('entry_allcost');
		$data['entry_newcost'] = $this->language->get('entry_newcost');
		$data['entry_tax_class'] = $this->language->get('entry_tax_class');
		$data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
		$data['entry_status'] = $this->language->get('entry_status');
		$data['entry_sort_order'] = $this->language->get('entry_sort_order');

		$data['button_add'] = $this->language->get('button_add');
		$data['button_remove'] = $this->language->get('button_remove');
		$data['button_save'] = $this->language->get('button_save');
		$data['button_cancel'] = $this->language->get('button_cancel');

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_extension'),
			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('extension/shipping/cs', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['action'] = $this->url->link('extension/shipping/cs', 'user_token=' . $this->session->data['user_token'], true);

		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true);

		$this->load->model('localisation/language');
		
		$data['languages'] = $this->model_localisation_language->getLanguages();
		
		if (isset($this->request->post['cs'])) {
			$data['multiple_shippings']['cs'] = $this->request->post['cs'];
		} else {
			$data['multiple_shippings'] = $this->model_setting_setting->getSetting('cs');
		}

		$this->load->model('localisation/tax_class');

		$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();

		$this->load->model('localisation/geo_zone');

		$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();


		//Error
		
		if (isset($this->error['name'])) {
			$data['error_name'] = $this->error['name'];
		} else {
			$data['error_name'] = array();
		}
		
		if (isset($this->error['shipping_option'])) {
			$data['error_shipping_option'] = $this->error['shipping_option'];
		} else {
			$data['error_shipping_option'] = array();
		}
		
		if (isset($this->request->post['cs_group_shipping'])) {
			$data['cs_group_shipping'] = $this->request->post['cs_group_shipping'];
		} else {
			$data['cs_group_shipping'] = $this->config->get('cs_group_shipping');
		}

		if (isset($this->request->post['cs_status'])) {
			$data['cs_status'] = $this->request->post['cs_status'];
		} else {
			$data['cs_status'] = $this->config->get('cs_status');
		}

		if (isset($this->request->post['cs_sort_order'])) {
			$data['cs_sort_order'] = $this->request->post['cs_sort_order'];
		} else {
			$data['cs_sort_order'] = $this->config->get('cs_sort_order');
		}

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('extension/shipping/cs', $data));
	}

	protected function validate() {
		if (!$this->user->hasPermission('modify', 'extension/shipping/cs')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}
		
		foreach ($this->request->post['cs_group_shipping'] as $language_id => $value) {
			if ((utf8_strlen($value['shipping_name']) < 1) || (utf8_strlen($value['shipping_name']) > 64)) {
				$this->error['name'][$language_id] = $this->language->get('error_name');
			}
		}
		
		if (isset($this->request->post['cs'])) {
			foreach ($this->request->post['cs'] as $shipping_id => $shipping) { 
				foreach ($shipping['shipping_description'] as $language_id => $shipping_description) {
					if ((utf8_strlen($shipping_description['name']) < 1) || (utf8_strlen($shipping_description['name']) > 64)) {
						$this->error['shipping_option'][$shipping_id][$language_id] = $this->language->get('error_shipping_option');
					}
				}
			}
		}
		return !$this->error;
	}
}
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==


 

это переделанный шаблон:

Спойлер



{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-layout" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-layout" class="form-horizontal">
        <table class="table table-striped table-bordered table-hover">
           <tr>
              <td class="text-left">
              {% for language in languages %}
                <div class="input-group required">
                  <span class="input-group-addon">
                    <img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" />
                  </span>
                  <input type="text" name="cs_group_shipping[ {{ language.language_id }} ][shipping_name]" value="cs_group_shipping[language.language_id].shipping_name" placeholder="{{ entry_shipping_title }}" class="form-control" />
                </div>
                {% if error_name.language.language_id %}
                  <div class="text-danger">{{ error_name.language.language_id }}</div>
                {% endif %}
              {% endfor %}
              </td>
              <td colspan="4" style="min-width: 170px;"><select name="cs_status" id="input-status" class="form-control">
              {% if cs_status %}
              <option value="1" selected="selected">{{ text_enabled }}</option>
              <option value="0">{{ text_disabled }}</option>
              {% else %}
              <option value="1">{{ text_enabled }}</option>
              <option value="0" selected="selected">{{ text_disabled }}</option>
              {% endif %}
            </select></td>
             <td class="text-right" style="min-width: 170px;"><input type="text" name="cs_sort_order" value="{{ cs_sort_order }}" placeholder="{{ entry_sort_order }}" class="form-control" /></td>
          </tr> 
          </table>

            

           <table id="shiping" class="table table-striped table-bordered table-hover">
            <thead>
              <td class="required">{{ entry_name }}</td>
              <td>{{ entry_cost }}</td>
              <td>{{ entry_allcost }}</td>
              <td>{{ entry_newcost }}</td>
              <td>{{ entry_tax_class }}</td>
              <td>{{ entry_geo_zone }}</td>
            </thead>
            <tbody>
              {% set shipping_row = 0 %}
              {% if multiple_shippings.cs %}
                {% for multiple_shipping in multiple_shippings.cs %}
                <tr id="shipping-row{{ shipping_row }}">
                  <td class="text-left">
                    {% for language in languages %}
                      <div class="input-group required">
                        <span class="input-group-addon">
                          <img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" />
                        </span>
                        <input type="text" name="cs[{{ shipping_row }}][shipping_description][{{language.language_id}}][name]" 
                        value="{{ multiple_shipping.shipping_description }}[{{language_id }}]['name']; ?>" 
                        placeholder="{{ entry_name }}" class="form-control" />
                      </div>
                        
                      {% if error_shipping_option.shipping_row.language.language_id %}
                        <div class="text-danger">{{ error_shipping_option.shipping_row.language.language_id }}</div>
                      {% endif %}

                    {% endfor %}
                  </td>
                  
                <td class="text-right" style="min-width: 120px;"><input type="text" name="cs[{{shipping_row}}][cost]" value="{{multiple_shipping.cost}}" placeholder="{{entry_cost}}" class="form-control" /></td>
                  <td class="text-right" style="min-width: 120px;"><input type="text" name="cs[{{shipping_row}}][allcost]" value="{{multiple_shipping.allcost}}" placeholder="{{entry_allcost}}" class="form-control" /></td>
                  <td class="text-right" style="min-width: 120px;"><input type="text" name="cs[{{shipping_row}}][newcost]" value="{{multiple_shipping.newcost}}" placeholder="{{entry_newcost}}" class="form-control" /></td>
                  <td class="text-right" style="min-width: 170px;"><select name="cs[{{shipping_row}}][cs_tax_class_id]" id="input-tax-class" class="form-control">
                  <option value="0">{{text_none}}</option>
                  {% for tax_class in tax_classes %}
                  {% if tax_class.tax_class_id == multiple_shipping.cs_tax_class_id %}
                  <option value="{{ tax_class.tax_class_id }}" selected="selected">{{ tax_class.title }}</option>
                  {% else %}
                  <option value="{{ tax_class.tax_class_id }}">{{ tax_class.title }}</option>
                  {% endif %}
                  {% endfor %}
                </select></td>
                  <td class="text-right" style="min-width: 170px;"><select name="cs[{{ shipping_row }}][cs_geo_zone_id]" id="input-geo-zone" class="form-control">
                  <option value="0">{{ text_all_zones }}</option>
                  {% for geo_zone in geo_zones %}
                  {% if geo_zone.geo_zone_id == multiple_shipping.cs_geo_zone_id %}
                  <option value="{{ geo_zone.geo_zone_id }}" selected="selected">{{ geo_zone.name }}</option>
                  {% else %}
                  <option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name }}</option>
                  {% endif %}
                  {% endfor %}
                </select></td>
                  <td class="text-left"><button type="button" onclick="$('#shipping-row{{ shipping_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
                </tr>

                {% set shipping_row = shipping_row + 1 %}
                {% endfor %}
             {% endif %}
           </tbody>
            <tfoot>
              <tr>
                <td colspan="6"></td>
                <td class="text-left"><button type="button" onclick="addShipping();" data-toggle="tooltip" title="{{ button_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
              </tr>
            </tfoot>
          </table>
          </form>


      </div>
    </div>
  </div>

  {% block javascripts %}
<script>
var shipping_row = {{ shipping_row }};

function addShipping() {
	html  = '<tr id="shipping-row' + shipping_row + '">';
	html += '<td class="text-left">';
	{% for language in languages %}
	html += '<div class="input-group required"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>';
	html += '  <input type="text" name="cs[' + shipping_row + '][shipping_description][{{ language.language_id }}][name]" value="" placeholder="{{ entry_name }}" class="form-control" /></div>';
	{% endfor %}
	html += '</td>';
	html += '  <td class="text-left"><input type="text" name="cs[' + shipping_row + '][cost]" value="" placeholder="{{ entry_cost }}" class="form-control" /></td>';
    html += '  <td class="text-left"><input type="text" name="cs[' + shipping_row + '][allcost]" value="999999999999" placeholder="{{ entry_allcost }}" class="form-control" /></td>';
    html += '  <td class="text-left"><input type="text" name="cs[' + shipping_row + '][newcost]" value="" placeholder="{{ entry_newcost }}" class="form-control" /></td>';
	html += '  <td class="text-left"><select name="cs[' + shipping_row + '][cs_tax_class_id]" id="input-tax-class" class="form-control">';
    html += '  <option value="0">{{ text_none }}</option>';
    {% for tax_class in tax_classes %}
    html += '  <option value="{{ tax_class.tax_class_id }}">{{ tax_class.title }}</option>';
    {% endfor %}
    html += '  </select>';
	html += '  </td>';
	html += '  <td class="text-left"><select name="cs[' + shipping_row + '][cs_geo_zone_id]" id="input-geo-zone" class="form-control">';
    html += '  <option value="0">{{ text_none }}</option>';
    {% for geo_zone in geo_zones %}
    html += '  <option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name }}</option>';
    {% endfor %}
    html += '  </select>';
	html += '  </td>';
	html += '  <td class="text-left"><button type="button" onclick="$(\'#shipping-row' + shipping_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
	html += '</tr>';
	
	$('#shiping tbody').append(html);
	
	{% set shipping_row = shipping_row + 1 %}
}
</script>
{% endblock %}

</div>
{{ footer }}
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==


 

а это оригинальный шаблон:

Спойлер



<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-layout" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_edit; ?></h3>
      </div>
      <div class="panel-body">
        <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-layout" class="form-horizontal">
		  <table class="table table-striped table-bordered table-hover">
           <tr>
              <td class="text-left">
              <?php foreach($languages as $language){ ?><div class="input-group required">
                <span class="input-group-addon">
		              <img src="language/<?php echo $language["code"]; ?>/<?php echo $language["code"]; ?>.png" title="<?php echo $language["name"]; ?>" />
		            </span>
              <input type="text" name="cs_group_shipping[<?php echo $language['language_id']; ?>][shipping_name]" 
              value="<?php echo $cs_group_shipping[ $language['language_id']]['shipping_name'];?>" placeholder="<?php echo $entry_shipping_title; ?>" class="form-control" />
              </div>
              <?php if (isset($error_name[$language['language_id']])) { ?>
                    <div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
               <?php } ?>
              <?php } ?></td>
              <td colspan="4" style="min-width: 170px;"><select name="cs_status" id="input-status" class="form-control">
              <?php if ($cs_status) { ?>
              <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
              <option value="0"><?php echo $text_disabled; ?></option>
              <?php } else { ?>
              <option value="1"><?php echo $text_enabled; ?></option>
              <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
              <?php } ?>
            </select></td>
             <td class="text-right" style="min-width: 170px;"><input type="text" name="cs_sort_order" value="<?php echo $cs_sort_order; ?>" placeholder="<?php echo $entry_sort_order; ?>" class="form-control" /></td>
          </tr>	
          </table>
          <table id="shiping" class="table table-striped table-bordered table-hover">
          	<thead>
              <td class="required"><?php echo $entry_name;?></td>
              <td><?php echo $entry_cost;?></td>
		        <td><?php echo $entry_allcost;?></td>
		        <td><?php echo $entry_newcost;?></td>
              <td><?php echo $entry_tax_class;?></td>
              <td><?php echo $entry_geo_zone;?></td>
            </thead>
            <tbody>
              <?php $shipping_row = 0; ?>
              <?php if(!empty($multiple_shippings['cs'])){ ?>
                <?php foreach($multiple_shippings['cs'] as $multiple_shipping){ ?>
                <tr id="shipping-row<?php echo $shipping_row; ?>">
                  <td class="text-left"><?php foreach($languages as $language){ ?><div class="input-group required"><span class="input-group-addon">
<img src="language/<?php echo $language["code"]; ?>/<?php echo $language["code"]; ?>.png" title="<?php echo $language["name"]; ?>" />
</span><input type="text" name="cs[<?php echo $shipping_row; ?>][shipping_description][<?php echo $language['language_id']; ?>][name]" value="<?php echo $multiple_shipping['shipping_description'][$language['language_id']]['name']; ?>" placeholder="<?php echo $entry_name; ?>" class="form-control" />
                  </div>
                  <?php if (isset($error_shipping_option[$shipping_row][$language['language_id']])) { ?>
                  <div class="text-danger"><?php echo $error_shipping_option[$shipping_row][$language['language_id']]; ?></div>
                  <?php } ?>
                  <?php } ?>
                  </td>
                  <td class="text-right" style="min-width: 120px;"><input type="text" name="cs[<?php echo $shipping_row; ?>][cost]" value="<?php echo $multiple_shipping['cost']; ?>" placeholder="<?php echo $entry_cost; ?>" class="form-control" /></td>
                  <td class="text-right" style="min-width: 120px;"><input type="text" name="cs[<?php echo $shipping_row; ?>][allcost]" value="<?php echo $multiple_shipping['allcost']; ?>" placeholder="<?php echo $entry_allcost; ?>" class="form-control" /></td>
                  <td class="text-right" style="min-width: 120px;"><input type="text" name="cs[<?php echo $shipping_row; ?>][newcost]" value="<?php echo $multiple_shipping['newcost']; ?>" placeholder="<?php echo $entry_newcost; ?>" class="form-control" /></td>
                  <td class="text-right" style="min-width: 170px;"><select name="cs[<?php echo $shipping_row; ?>][cs_tax_class_id]" id="input-tax-class" class="form-control">
                  <option value="0"><?php echo $text_none; ?></option>
                  <?php foreach ($tax_classes as $tax_class) { ?>
                  <?php if ($tax_class['tax_class_id'] == $multiple_shipping['cs_tax_class_id']) { ?>
                  <option value="<?php echo $tax_class['tax_class_id']; ?>" selected="selected"><?php echo $tax_class['title']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $tax_class['tax_class_id']; ?>"><?php echo $tax_class['title']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
                  <td class="text-right" style="min-width: 170px;"><select name="cs[<?php echo $shipping_row; ?>][cs_geo_zone_id]" id="input-geo-zone" class="form-control">
                  <option value="0"><?php echo $text_all_zones; ?></option>
                  <?php foreach ($geo_zones as $geo_zone) { ?>
                  <?php if ($geo_zone['geo_zone_id'] == $multiple_shipping['cs_geo_zone_id']) { ?>
                  <option value="<?php echo $geo_zone['geo_zone_id']; ?>" selected="selected"><?php echo $geo_zone['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $geo_zone['geo_zone_id']; ?>"><?php echo $geo_zone['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
                  <td class="text-left"><button type="button" onclick="$('#shipping-row<?php echo $shipping_row; ?>').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
                </tr>
                <?php $shipping_row++; ?>
               <?php } ?>
             <?php } ?>
           </tbody>
            <tfoot>
              <tr>
                <td colspan="6"></td>
                <td class="text-left"><button type="button" onclick="addShipping();" data-toggle="tooltip" title="<?php echo $button_add; ?>" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
              </tr>
            </tfoot>
          </table>
        </form>
      </div>
    </div>
  </div>
<script type="text/javascript"><!--
var shipping_row = <?php echo $shipping_row; ?>;

function addShipping() {
	html  = '<tr id="shipping-row' + shipping_row + '">';
	html += '<td class="text-left">';
	<?php foreach($languages as $language){ ?>
	html += '<div class="input-group required"><span class="input-group-addon"><img src="language/<?php echo $language['code']; ?>/<?php echo $language['code']; ?>.png" title="<?php echo $language['name']; ?>" /></span>';
	html += '  <input type="text" name="cs[' + shipping_row + '][shipping_description][<?php echo $language['language_id']; ?>][name]" value="" placeholder="<?php echo $entry_name; ?>" class="form-control" /></div>';
	<?php } ?>
	html += '</td>';
	html += '  <td class="text-left"><input type="text" name="cs[' + shipping_row + '][cost]" value="" placeholder="<?php echo $entry_cost; ?>" class="form-control" /></td>';
    html += '  <td class="text-left"><input type="text" name="cs[' + shipping_row + '][allcost]" value="999999999999" placeholder="<?php echo $entry_allcost; ?>" class="form-control" /></td>';
    html += '  <td class="text-left"><input type="text" name="cs[' + shipping_row + '][newcost]" value="" placeholder="<?php echo $entry_newcost; ?>" class="form-control" /></td>';
	html += '  <td class="text-left"><select name="cs[' + shipping_row + '][cs_tax_class_id]" id="input-tax-class" class="form-control">';
    html += '  <option value="0"><?php echo $text_none; ?></option>';
    <?php foreach ($tax_classes as $tax_class) { ?>
    html += '  <option value="<?php echo $tax_class['tax_class_id']; ?>"><?php echo $tax_class['title']; ?></option>';
    <?php } ?>
    html += '  </select>';
	html += '  </td>';
	html += '  <td class="text-left"><select name="cs[' + shipping_row + '][cs_geo_zone_id]" id="input-geo-zone" class="form-control">';
    html += '  <option value="0"><?php echo $text_none; ?></option>';
    <?php foreach ($geo_zones as $geo_zone) { ?>
    html += '  <option value="<?php echo $geo_zone['geo_zone_id']; ?>"><?php echo $geo_zone['name']; ?></option>';
    <?php } ?>
    html += '  </select>';
	html += '  </td>';
	html += '  <td class="text-left"><button type="button" onclick="$(\'#shipping-row' + shipping_row + '\').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
	html += '</tr>';
	
	$('#shiping tbody').append(html);
	
	shipping_row++;
}
//--></script></div>
<?php echo $footer; ?>
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==


 

 

Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер
Спойлер

Для этого придумали спойлер :ph34r:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to post
Share on other sites
value="<?php echo $cs_group_shipping[ $language['language_id']]['shipping_name'];?>"

 

value="{{ cs_group_shipping[ language.language_id].shipping_name }}"

обратите внимание на пробел перед language (если он у вас действительно есть в php варианте)

Link to post
Share on other sites
7 минут назад, AlexDW сказал:

value="<?php echo $cs_group_shipping[ $language['language_id']]['shipping_name'];?>"

 


value="{{ cs_group_shipping[ language.language_id].shipping_name }}"

обратите внимание на пробел перед language (если он у вас действительно есть в php варианте)

а что такого в этом пробеле? это просто массив в массиве

Link to post
Share on other sites

да по старой памяти наложилось :ugeek:

вообще - должно работать

 

попробуйте так

value="{{ cs_group_shipping[language.language_id] ? cs_group_shipping[language.language_id].shipping_name }}"

 

Link to post
Share on other sites

Я уже обратил внимание на пробел, но в другом месте..
 

value="<?php echo $cs_group_shipping[ $language['language_id']]['shipping_name'];?>"

php это съест

cs_group_shipping[ language.language_id].shipping_name

твиг - не знаю

cs_group_shipping[language.language_id].shipping_name

Link to post
Share on other sites

Всем привет. Попробовал вчера ваши предложения, но почему-то не работает. То ли лыжи не едут, то ли я долбанутый. Должна вернуться строка, а возвращается массив. В БД сохранилось вот это значение: {" 1 ":{"shipping_name":"7"}}

Edited by abonnent
Link to post
Share on other sites

Кеш твига  обновлён после изменений?

Link to post
Share on other sites

 

В twig через точку идет обращение к объекту. Доступ к элементам многомерного массива осуществляется как в php 

 

{{ myVar[0][1] }}
{{ myVar[0][a(n-2)] }}

Twig как получить значение из двумерного массива - PHP

Link to post
Share on other sites

Есть вопрос по контроллеру. В контроллере грузишь языковые переменные, разве в ОС3 надо их грузить?

Link to post
Share on other sites

32 минуты назад, lexxkrt сказал:

разве в ОС3 надо их грузить?

Не обязательно, это делает событие

 

Link to post
Share on other sites
11 часов назад, chukcha сказал:

твиг - не знаю

твиг тоже

 

по теме, тс явно с самим массивом намудрил

конструкция выше у меня прекрасно работает

Link to post
Share on other sites
7 минут назад, AlexDW сказал:

твиг тоже

 

по теме, тс явно с самим массивом намудрил

конструкция выше у меня прекрасно работает

в общем дело в том, что значение (value) не выводится

Link to post
Share on other sites
1 минуту назад, chukcha сказал:

а оно есть?

 

посмотрите <input name

ну, конечно, я же его записываю. но после сохранения ничего не выводится

Link to post
Share on other sites
23 минуты назад, chukcha сказал:

Я вам показал лишний пробел, вы исправили?

Только вечером будет возможность проверить

Link to post
Share on other sites
3 часа назад, chukcha сказал:

Я вам показал лишний пробел, вы исправили?

В общем все пробелы удалил, но это не решило ничего. Данные в БД улетают, но не выводятся

Link to post
Share on other sites

кто-нибудь знает как распечатать массив в твиге? print_r .

когда пишу это {{ dump(user) }} выводится белая страница

Edited by abonnent
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.