Yii Framework Forum: Yii2 Ajax Popup Form - BaseUrl Class - Scheme - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii2 Ajax Popup Form - BaseUrl Class - Scheme Rate Topic: -----

#1 User is offline   Sreenadh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 07-May 14
  • Location:Kochi, Kerala, India

Posted 21 January 2017 - 02:45 AM

Scenario:
1. Customer form
2. Order Form

Loading Customer create form (customer/create) in order form via Ajax popup dialog. The action of the customer create form will be "create" ( jQuery('#customer-create).attr("action") )

The form will be submitted to order/create instead of customer/create.

Solution 1:
ActiveForm::begin(['action' => Url::to('customer/create', true ]);

The second parameter of Url::to determines whether to return relative url or absolute url. True means absolute URL.

Solution 2: Override core helper
Copy vendor/yiisoft/yii2/helpers/BaseUrl.php to components ( common/components or @app/components )
Then change
public static function to($url = '', $scheme = false)

to
public static function to($url = '', $scheme = true)


The add the following code to entry script web/index.php
Yii::$classMap['yii\helpers\BaseUrl'] = '@common/components/BaseUrl.php';

Or
Yii::$classMap['yii\helpers\BaseUrl'] = '@app/components/BaseUrl.php';

Developer - Greenfoss Technologies
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users