A
A
Andrey Boychenko2015-09-27 19:14:56
Joomla
Andrey Boychenko, 2015-09-27 19:14:56

Custom fields $field['formcode']?

Good evening! Let's say I created a "Phone number" field in the VM3 settings. It is displayed in the shopping cart and is mandatory, but I do not like its appearance, but the view can be edited using CSS. Then I want the field name to be displayed not to the left of the field itself, but, say, in the placeholder. Here I ran into a problem, because. I can't find the file that generates the custom field.
More precisely, in the default_cartfields.php file at components\com_virtuemart\views\cart\tmpl\ there is the following code:

<?php
// Status Of Delimiter
$closeDelimiter = false;
$openTable = true;
$hiddenFields = '';

if(!empty($this->userFieldsCart['fields'])) {

  // Output: Userfields
  foreach($this->userFieldsCart['fields'] as $field) {
  ?>
  <fieldset class="vm-fieldset1-<?php echo str_replace('_','-',$field['name']) ?>">

    <div  class="cart <?php echo str_replace('_','-',$field['name']) ?>" title="<?php echo strip_tags($field['description']) ?>">

    <?php
    if ($field['hidden'] == true) {
      // We collect all hidden fields
      // and output them at the end
      $hiddenFields .= $field['formcode'] . "\n";
    } else { ?>
        <?php echo $field['formcode'] . "ss"; ?>
        <?php } ?>
      </div>
  </fieldset>
  <?php
  }
  // Output: Hidden Fields
  echo $hiddenFields;
}
?>

The following code is responsible for the direct generation of the fields in the cart:
<?php
    if ($field['hidden'] == true) {
      // We collect all hidden fields
      // and output them at the end
      $hiddenFields .= $field['formcode'] . "\n";
    } else { ?>
        <?php echo $field['formcode'] . "ss"; ?>
        <?php } ?>

Actually the question is where the file is located (I suppose the view in which the fields displayed using this entry live
<?php echo $field['formcode']; ?>
) And here is the screenshot itself, just in case.
897084f847474f7198a2dba01a5b4154.JPG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
2715643, 2015-12-19
@2715643

in Virtuemart 3
/administrator/components/com_virtuemart/models/userfields.php
line 929

case 'webaddress':

              $_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="'
              . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
              . '" value="' . $_return['fields'][$_fld->name]['value'] .'" '
              . ($_fld->required ? ' class="required"' : '')
              . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
              . $readonly . ' /> ';
              break;

change to
case 'webaddress':

              $_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="'
              . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
              . '" value="' . $_return['fields'][$_fld->name]['value'] .'" 
              placeholder="'.$_fld->title.($_fld->required ? '*' : '').'"'
              . ($_fld->required ? ' class="required"' : '')
              . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
              . $readonly . ' /> ';
              break;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question