Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Dealing wiht Form in X-Cart 5

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-03-2018, 02:48 AM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Dealing wiht Form in X-Cart 5

Hello, I create a form. This is my class that define my form widget :
<?php

namespace XLite\Module\Fdmteam\Xretur\View\Model ;

class ReturForm extends \XLite\View\Model\AModel
{
/**
* @inheritdoc
*/
public function __construct($params = [], $sections = [])
{
$this->schemaDefault = [
'name' => [
self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text',
self::SCHEMA_LABEL => static::t('Name'),
self::SCHEMA_PLACEHOLDER => static::t('Name'),
self::SCHEMA_REQUIRED => true,
],
'email' => [
self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text\Email',
self::SCHEMA_LABEL => static::t('Email'),
self::SCHEMA_PLACEHOLDER => static::t('Email'),
self::SCHEMA_REQUIRED => true,
],
'phone' => [
self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text\Phone',
self::SCHEMA_LABEL => static::t('Phone'),
self::SCHEMA_PLACEHOLDER => static::t('Phone'),
self::SCHEMA_REQUIRED => true,
],
'invoice_number' => [
self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text\Integer',
self::SCHEMA_LABEL => static::t('Invoice'),
self::SCHEMA_PLACEHOLDER => static::t('Invoice Number'),
self::SCHEMA_REQUIRED => true,
],
'reason' => [
self::SCHEMA_CLASS => '\XLite\Module\Fdmteam\Xretur\View\FormField\Selec t\Reasons',
self::SCHEMA_LABEL => static::t('Reason'),
self::SCHEMA_PLACEHOLDER => static::t('Reason'),
self::SCHEMA_REQUIRED => true,
\XLite\View\FormField\AFormField::FIELD_TYPE_SELEC T => true,
],
'desire' => [
self::SCHEMA_CLASS => '\XLite\Module\Fdmteam\Xretur\View\FormField\Selec t\Desireds',
self::SCHEMA_LABEL => static::t('Desired'),
self::SCHEMA_PLACEHOLDER => static::t('Desired'),
self::SCHEMA_REQUIRED => true,
\XLite\View\FormField\AFormField::FIELD_TYPE_SELEC T => true,
],
'date' => [
self::SCHEMA_CLASS => '\XLite\Module\Fdmteam\Xretur\View\FormField\Input \Text\DatePicker',
self::SCHEMA_LABEL => static::t('Date'),
self::SCHEMA_REQUIRED => true,
self::SCHEMA_PLACEHOLDER => static::t('Date'),
\XLite\View\FormField\AFormField::PARAM_FIELD_ONLY => false,
],
'message' => [
self::SCHEMA_CLASS => '\XLite\View\FormField\Textarea\Simple',
self::SCHEMA_LABEL => static::t('Message'),
self::SCHEMA_PLACEHOLDER => static::t('Message'),
self::SCHEMA_REQUIRED => true,
\XLite\View\FormField\Textarea\ATextarea::PARAM_RO WS => 5,
\XLite\View\FormField\Textarea\ATextarea::PARAM_CO LS => 21
],
'table' => [
self::SCHEMA_CLASS => '\XLite\Module\Fdmteam\Xretur\View\FormField\Table \CustomTable',
self::SCHEMA_LABEL => static::t('Table'),
self::SCHEMA_PLACEHOLDER => static::t('Aici trebuie sa pun tabelul'),
self::SCHEMA_REQUIRED => true,
\XLite\View\FormField\AFormField::PARAM_FIELD_ONLY => false,
],
];

parent::__construct($params, $sections);
}

public function getModelId()
{
return \XLite\Core\Request::getInstance()->id;
}

protected function getDefaultModelObject()
{
$model = $this->getModelId()
? \XLite\Core\Database::getRepo('XLite\Module\Fdmtea m\Xretur\Model\FormRetur')->find($this->getModelId())
: null;

return $model ?: new \XLite\Module\Fdmteam\Xretur\Model\FormRetur ;
}

protected function getFormClass()
{
return '\XLite\Module\Fdmteam\Xretur\View\Form\Model\Retu rForm';
}

/**
* Return list of the "Button" widgets
*
* @return array
*/
protected function getFormButtons()
{
$result = parent::getFormButtons();

$result['submit'] = new \XLite\View\Button\Submit(
[
\XLite\View\Button\AButton::PARAM_LABEL => static::t('Send Form'),
\XLite\View\Button\AButton::PARAM_BTN_TYPE => 'btn regular-main-button submit'
]
);

return $result;
}
}

Is there a way to split this form in two separated columns when i render the widget in my view without apply any particular css styles or something, only using x-cart configs ?!
This is my view
<div class="form-wrapper">
{{ widget('\\XLite\\Module\\Fdmteam\\Xretur\\View\\Mo del\\ReturForm') }}
</div>
__________________
Soptareanu Alex
Reply With Quote
  #2  
Old 05-06-2018, 11:53 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Dealing wiht Form in X-Cart 5

There is no built-in way to display the form in two columns, however you can split it into two "sections" and make it appear as two columns with CSS.

Here is an example from the PayPal module:
PHP Code:
namespace XLite\Module\CDev\Paypal\View\Model;

abstract class 
ASettings extends \XLite\View\Model\AModel
{
    
/**
     * Form sections
     */
    
const SECTION_ACCOUNT    'account';
    const 
SECTION_ADDITIONAL 'additional';

    protected 
$schemaAccount = array(
        
// ...
        
'user' => array(
            
self::SCHEMA_CLASS    => 'XLite\View\FormField\Input\Text',
            
self::SCHEMA_LABEL    => 'User',
            
self::SCHEMA_HELP     => 'PayPal recommends entering a User Login here instead of your Merchant Login',
            
self::SCHEMA_REQUIRED => true,
        ),
        
// ...
    
);

    protected 
$schemaAdditional = array(
        
// ...
        
'mode' => array(
            
self::SCHEMA_CLASS    => 'XLite\View\FormField\Select\TestLiveMode',
            
self::SCHEMA_LABEL    => 'Test/Live mode',
            
self::SCHEMA_REQUIRED => false,
        ),
        
// ...
    
);

    
// ...

    
public function __construct(array $params = array(), array $sections = array())
    {
        
$this->sections $this->getSettingsSections() + $this->sections;
        
parent::__construct($params$sections);
    }

    protected function 
getSettingsSections()
    {
        return array(
            static::
SECTION_ACCOUNT    => 'Your account settings',
            static::
SECTION_ADDITIONAL => 'Additional settings',
        );
    }

    
// ...


__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
Soptareanu @Alex (05-07-2018)
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:51 PM.

   

 
X-Cart forums © 2001-2020